diff --git a/.github/workflows/ruff.yaml b/.github/workflows/ruff.yaml index 50407e5..5ccbb1c 100644 --- a/.github/workflows/ruff.yaml +++ b/.github/workflows/ruff.yaml @@ -1,22 +1,24 @@ name: Ruff Formatting & Linting -on: [push, pull_request] +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] jobs: - ruff: - name: Run Ruff Checks + build: runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Run Ruff (Lint & Format Check) - uses: astral-sh/ruff-action@v1 + - uses: actions/checkout@v4 + - name: Install Python + uses: actions/setup-python@v5 with: - args: "check . --output-format=concise" + python-version: "3.11" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install ruff - - name: Run Ruff Format Check - uses: astral-sh/ruff-action@v1 - with: - args: "format --check ." + - name: Run Ruff + run: ruff check --output-format=github . && ruff format --check \ No newline at end of file diff --git a/src/auto_archiver/modules/generic_extractor/generic_extractor.py b/src/auto_archiver/modules/generic_extractor/generic_extractor.py index 4e408df..c06e622 100644 --- a/src/auto_archiver/modules/generic_extractor/generic_extractor.py +++ b/src/auto_archiver/modules/generic_extractor/generic_extractor.py @@ -396,7 +396,7 @@ class GenericExtractor(Extractor): item.set("replaced_url", url) ydl_options = { - "outtmpl": os.path.join(self.tmp_dir, f"%(id)s.%(ext)s"), + "outtmpl": os.path.join(self.tmp_dir, "%(id)s.%(ext)s"), "quiet": False, "noplaylist": not self.allow_playlist, "writesubtitles": self.subtitles, diff --git a/src/auto_archiver/modules/tiktok_tikwm_extractor/__init__.py b/src/auto_archiver/modules/tiktok_tikwm_extractor/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/auto_archiver/modules/tiktok_tikwm_extractor/__manifest__.py b/src/auto_archiver/modules/tiktok_tikwm_extractor/__manifest__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/auto_archiver/modules/tiktok_tikwm_extractor/tiktok_tikwm_extractor.py b/src/auto_archiver/modules/tiktok_tikwm_extractor/tiktok_tikwm_extractor.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/extractors/test_tiktok_tikwm_extractor.py b/tests/extractors/test_tiktok_tikwm_extractor.py index b4b10ba..d04d7e4 100644 --- a/tests/extractors/test_tiktok_tikwm_extractor.py +++ b/tests/extractors/test_tiktok_tikwm_extractor.py @@ -38,7 +38,7 @@ class TestTiktokTikwmExtractor(TestExtractorBase): mock_get.return_value.status_code = 200 mock_get.return_value.json.side_effect = ValueError with caplog.at_level("DEBUG"): - assert self.extractor.download(make_item(self.VALID_EXAMPLE_URL)) == False + assert self.extractor.download(make_item(self.VALID_EXAMPLE_URL)) is False mock_get.assert_called_once() mock_get.return_value.json.assert_called_once() # first message is just the 'Skipping using ytdlp to download files for TikTok' message @@ -49,7 +49,7 @@ class TestTiktokTikwmExtractor(TestExtractorBase): mock_get.return_value.json.side_effect = Exception with caplog.at_level("ERROR"): - assert self.extractor.download(make_item(self.VALID_EXAMPLE_URL)) == False + assert self.extractor.download(make_item(self.VALID_EXAMPLE_URL)) is False mock_get.assert_called() assert mock_get.call_count == 2 assert mock_get.return_value.json.call_count == 2 @@ -69,7 +69,7 @@ class TestTiktokTikwmExtractor(TestExtractorBase): mock_get.return_value.status_code = 200 mock_get.return_value.json.return_value = response with caplog.at_level("DEBUG"): - assert self.extractor.download(make_item(self.VALID_EXAMPLE_URL)) == False + assert self.extractor.download(make_item(self.VALID_EXAMPLE_URL)) is False mock_get.assert_called_once() mock_get.return_value.json.assert_called_once() assert "failed to get a valid response from tikwm.com" in caplog.text @@ -82,10 +82,9 @@ class TestTiktokTikwmExtractor(TestExtractorBase): ({"data": {"play": "url"}}, True), ], ) - def test_correct_extraction(self, mock_get, make_item, response, has_vid): + def test_correct_extraction(self, mock_get, make_item, response, has_vid, mocker): mock_get.return_value.status_code = 200 mock_get.return_value.json.return_value = {"msg": "success", **response} - result = self.extractor.download(make_item(self.VALID_EXAMPLE_URL)) if not has_vid: assert result is False @@ -95,13 +94,8 @@ class TestTiktokTikwmExtractor(TestExtractorBase): mock_get.assert_called() assert mock_get.call_count == 1 + int(has_vid) mock_get.return_value.json.assert_called_once() - if not has_vid: - mock_logger.error.assert_called_once() - assert mock_logger.error.call_args[0][0].startswith("no valid video URL found") - else: - mock_logger.error.assert_not_called() - def test_correct_extraction(self, mock_get, make_item): + def test_correct_data_extracted(self, mock_get, make_item): mock_get.return_value.status_code = 200 mock_get.return_value.json.return_value = { "msg": "success",