From e19ce5b6b92c0d0f59e28d0d10aa1bb8acd20eed Mon Sep 17 00:00:00 2001 From: benoit74 Date: Mon, 21 Oct 2024 12:42:57 +0000 Subject: [PATCH] Use proper ZIM metadata key for `Scraper` and `Tags` --- .github/workflows/Tests.yml | 2 +- CHANGELOG.md | 1 + scraper/src/youtube2zim/scraper.py | 4 ++-- scraper/tests-integration/integration.py | 14 ++++++++------ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index 55c9a7ee..5f5c21d8 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -100,7 +100,7 @@ jobs: env: YOUTUBE_API_KEY: ${{ secrets.YOUTUBE_API_KEY }} OPTIMIZATION_CACHE_URL: ${{ secrets.OPTIMIZATION_CACHE_URL }} - run: docker run -v $PWD/output:/output youtube2zim youtube2zim --api-key "$YOUTUBE_API_KEY" --optimization-cache "$OPTIMIZATION_CACHE_URL" --type channel --id "UC8elThf5TGMpQfQc_VE917Q" --name "openZIM_testing" --zim-file "openZIM_testing.zim" + run: docker run -v $PWD/output:/output youtube2zim youtube2zim --api-key "$YOUTUBE_API_KEY" --optimization-cache "$OPTIMIZATION_CACHE_URL" --type channel --id "UC8elThf5TGMpQfQc_VE917Q" --name "tests_en_openzim-testing" --zim-file "openZIM_testing.zim" --tags "tEsTing,x-mark:yes" - name: Run integration test suite run: docker run -v $PWD/scraper/tests-integration/integration.py:/src/scraper/tests-integration/integration.py -v $PWD/output:/output youtube2zim bash -c "pip install pytest; pytest -v /src/scraper/tests-integration/integration.py" diff --git a/CHANGELOG.md b/CHANGELOG.md index fd4ff0b6..dd71e3b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Filter-out non-public videos and properly cleanup unsuccessful videos (#362) +- Use proper ZIM metadata key for `Scraper` and `Tags` (#369) ## [3.2.0] - 2024-10-11 diff --git a/scraper/src/youtube2zim/scraper.py b/scraper/src/youtube2zim/scraper.py index 288de24b..b1e94b3f 100644 --- a/scraper/src/youtube2zim/scraper.py +++ b/scraper/src/youtube2zim/scraper.py @@ -382,8 +382,8 @@ def run(self): LongDescription=self.long_description, Creator=self.creator, Publisher=self.publisher, - tags=";".join(self.tags) if self.tags else "", - scraper=SCRAPER, + Tags=";".join(self.tags) if self.tags else "", + Scraper=SCRAPER, Date=datetime.date.today(), Illustration_48x48_at_1=illustration_data, ) diff --git a/scraper/tests-integration/integration.py b/scraper/tests-integration/integration.py index 1a0d4ae5..bf6ca6ad 100644 --- a/scraper/tests-integration/integration.py +++ b/scraper/tests-integration/integration.py @@ -24,12 +24,14 @@ def test_zim_metadata(): zim_fh = Archive(ZIM_FILE_PATH) - assert "youtube2zim " in zim_fh.get_text_metadata("scraper") - assert "openZIM_testing" in zim_fh.get_text_metadata("Title") - assert "-" in zim_fh.get_text_metadata("Description") - assert "en" in zim_fh.get_text_metadata("Language") - assert "openZIM" in zim_fh.get_text_metadata("Publisher") - assert "openZIM_testing" in zim_fh.get_text_metadata("Creator") + assert "youtube2zim " in zim_fh.get_text_metadata("Scraper") + assert zim_fh.get_text_metadata("Tags") == "tEsTing;x-mark:yes;_videos:yes" + assert zim_fh.get_text_metadata("Title") == "openZIM_testing" + assert zim_fh.get_text_metadata("Description") == "-" + assert zim_fh.get_text_metadata("Language") == "eng" + assert zim_fh.get_text_metadata("Name") == "tests_en_openzim-testing" + assert zim_fh.get_text_metadata("Publisher") == "openZIM" + assert zim_fh.get_text_metadata("Creator") == "Youtube Channel “openZIM_testing”" assert zim_fh.get_item("profile.jpg").mimetype == "image/jpeg" assert zim_fh.get_item("favicon.png").mimetype == "image/png"