Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Tatsh committed Mar 5, 2025
1 parent 5ab1834 commit 9fc7f4d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
10 changes: 8 additions & 2 deletions instagram_archiver/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ class AuthenticationError(Exception):
pass


class CSRFTokenNotFound(AuthenticationError):
pass


class InstagramClient:
"""The client."""
def __init__(self,
Expand Down Expand Up @@ -118,8 +122,10 @@ def _setup_session(self,
})
r = self._get_rate_limited('https://www.instagram.com', return_json=False)
m = list(re.finditer(r'{"csrf_token":"([^"]+)"', r.text))
assert len(m) == 1, m
self._session.headers.update({'x-csrftoken': m[0].group(1)})
try:
self._session.headers.update({'x-csrftoken': m[0].group(1)})
except IndexError as e:
raise CSRFTokenNotFound from e

def _save_to_log(self, url: str) -> None:
if self._no_log:
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"gen-manpage": "sphinx-build -T -E -b man -d docs/_build/doctrees -D language=en docs man",
"mypy": "poetry run mypy .",
"qa": "yarn mypy && yarn ruff && yarn check-spelling && yarn check-formatting",
"ruff": "poetry run ruff .",
"ruff:fix": "poetry run ruff --fix .",
"ruff": "poetry run ruff check .",
"ruff:fix": "poetry run ruff check --fix .",
"test": "poetry run pytest"
},
"version": "0.0.1"
Expand Down
14 changes: 8 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,13 @@ mock_use_standalone_module = true

[tool.ruff]
cache-dir = "~/.cache/ruff"
extend-ignore = ["C408", "PTH123", "Q000", "Q001", "Q003", "T201", "TD002", "TD003", "TD004"]
namespace-packages = ["docs", "tests"]
line-length = 100
target-version = "py311"
unsafe-fixes = true

[tool.ruff.lint]
extend-ignore = ["C408", "PTH123", "Q000", "Q001", "Q003", "T201", "TD002", "TD003", "TD004"]
extend-select = [
"A",
"ASYNC",
Expand Down Expand Up @@ -188,7 +193,7 @@ extend-select = [
"PLR0133",
"PLR0206",
"PLR0402",
"PLR1701",
"SIM101",
"PLR1711",
"PLR1714",
"PLR1722",
Expand Down Expand Up @@ -226,11 +231,8 @@ extend-select = [
"UP",
"YTT",
]
line-length = 100
target-version = "py311"
unsafe-fixes = true

[tool.ruff.flake8-quotes]
[tool.ruff.lint.flake8-quotes]
inline-quotes = "single"
multiline-quotes = "single"

Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ def pytest_internalerror(excinfo: pytest.ExceptionInfo[BaseException]) -> NoRetu
raise excinfo.value


@pytest.fixture()
@pytest.fixture
def runner() -> CliRunner:
return CliRunner()

0 comments on commit 9fc7f4d

Please sign in to comment.