From dbe71bb1c7404d50ff8d2bafdbf3d16cbb264915 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Sat, 8 Oct 2022 00:20:12 -0700 Subject: [PATCH] [BUGFIX] Fix split_by_chapters tests, refactor ytdl option file (#278) --- .../subscription_ytdl_options.py | 59 ++++--------------- .../plugins/split_by_chapters_video.json | 44 +++++++------- ...ters_with_regex_no_chapters_video_pass.txt | 2 +- .../split_by_chapters_with_regex_video.json | 44 +++++++------- 4 files changed, 56 insertions(+), 93 deletions(-) diff --git a/src/ytdl_sub/subscriptions/subscription_ytdl_options.py b/src/ytdl_sub/subscriptions/subscription_ytdl_options.py index 771437ae..7096ecd9 100644 --- a/src/ytdl_sub/subscriptions/subscription_ytdl_options.py +++ b/src/ytdl_sub/subscriptions/subscription_ytdl_options.py @@ -84,49 +84,12 @@ class SubscriptionYTDLOptions: return ytdl_options - @property - def _audio_extract_options(self) -> Dict: - if not (audio_extract_plugin := self._get_plugin(AudioExtractPlugin)): + def _plugin_ytdl_options(self, plugin: Type[PluginT]) -> Dict: + if not (audio_extract_plugin := self._get_plugin(plugin)): return {} return audio_extract_plugin.ytdl_options() - @property - def _subtitle_options(self) -> Dict: - if not (subtitle_plugin := self._get_plugin(SubtitlesPlugin)): - return {} - - if not self._downloader.supports_subtitles: - # TODO: warn here - return {} - - return subtitle_plugin.ytdl_options() - - @property - def _chapter_options(self) -> Dict: - if not (chapters_plugin := self._get_plugin(ChaptersPlugin)): - return {} - - if not self._downloader.supports_chapters: - # TODO: warn here - return {} - - return chapters_plugin.ytdl_options() - - @property - def _date_range_options(self) -> Dict: - if not (date_range_plugin := self._get_plugin(DateRangePlugin)): - return {} - - return date_range_plugin.ytdl_options() - - @property - def _file_convert_options(self) -> Dict: - if not (file_convert_plugin := self._get_plugin(FileConvertPlugin)): - return {} - - return file_convert_plugin.ytdl_options() - @property def _user_ytdl_options(self) -> Dict: return self._preset.ytdl_options.dict @@ -141,21 +104,21 @@ class SubscriptionYTDLOptions: ytdl_options_builder = YTDLOptionsBuilder().add(self._global_options) if self._dry_run: ytdl_options_builder.add( - self._date_range_options, - self._file_convert_options, - self._subtitle_options, - self._chapter_options, + self._plugin_ytdl_options(DateRangePlugin), + self._plugin_ytdl_options(FileConvertPlugin), + self._plugin_ytdl_options(SubtitlesPlugin), + self._plugin_ytdl_options(ChaptersPlugin), self._user_ytdl_options, # user ytdl options... self._dry_run_options, # then dry-run ) else: ytdl_options_builder.add( self._output_options, - self._date_range_options, - self._file_convert_options, - self._subtitle_options, - self._chapter_options, - self._audio_extract_options, + self._plugin_ytdl_options(DateRangePlugin), + self._plugin_ytdl_options(FileConvertPlugin), + self._plugin_ytdl_options(SubtitlesPlugin), + self._plugin_ytdl_options(ChaptersPlugin), + self._plugin_ytdl_options(AudioExtractPlugin), self._user_ytdl_options, # user ytdl options last ) diff --git a/tests/resources/expected_downloads_summaries/plugins/split_by_chapters_video.json b/tests/resources/expected_downloads_summaries/plugins/split_by_chapters_video.json index 4d42f14f..0d401a13 100644 --- a/tests/resources/expected_downloads_summaries/plugins/split_by_chapters_video.json +++ b/tests/resources/expected_downloads_summaries/plugins/split_by_chapters_video.json @@ -1,25 +1,25 @@ { - "01. Intro (Feat. Racheal Ofori & Barney Artist).info.json": "94a46b3263d7a0c144371e19107d3cf6", - "02. Answers (Feat. Rick David & Kaya Thomas - Dyke).info.json": "53748da13a12862098594051041a84d1", - "03. Blaze (Feat. Kaya Thomas - Dyke).info.json": "1dfe88b81ad1e6bd25b9ce3a94b0ce1e", - "04. What If (Interlude).info.json": "65b165b1d2ec5184fa7894350b4594e1", - "05. No Peace (Feat. Tom Misch).info.json": "c47761519802a1a9f2078c1ffa58ab05", - "06. Closer (Feat. Lester Duval).info.json": "0fa1a9de65f828e35825c0431c7fc72e", - "07. Delusions: Rumination (Interlude) (Feat. Racheal Ofori).info.json": "fa8566864fd40d358f932a8e701f159e", - "08. Dreams (Feat. Carmody).info.json": "366b8c6d86ac3f4978916acf0f770f9a", - "09. Dreaming (Interlude) (Feat. Racheal Ofori).info.json": "79a5c6131e95d943f3ca8e97e9e3fcf3", - "10. Hopeful (Feat. Jordan Rakei).info.json": "a3b98eea72b55353fb05250beafe6634", - "11. Sunrise (Pillows) (Feat. Emmavie).info.json": "8d0ab69f6b93bed6737f3f04e51e9a24", - "Alfa Mist - Nocturne [Full Album]/01 - 01. Intro (Feat. Racheal Ofori & Barney Artist).mp3": "ddc24257729f24055bf1b8dc06f8224c", - "Alfa Mist - Nocturne [Full Album]/02 - 02. Answers (Feat. Rick David & Kaya Thomas - Dyke).mp3": "10dd7f13c469bd51ffcf3f8ff3ed3d69", - "Alfa Mist - Nocturne [Full Album]/03 - 03. Blaze (Feat. Kaya Thomas - Dyke).mp3": "376722aaf08d1ef6dcba0aaf7a3b7a79", - "Alfa Mist - Nocturne [Full Album]/04 - 04. What If (Interlude).mp3": "2432e53f206149bb48d96eeb10eb1fb0", - "Alfa Mist - Nocturne [Full Album]/05 - 05. No Peace (Feat. Tom Misch).mp3": "f01f0f7777cb90656eb83c685b4e2942", - "Alfa Mist - Nocturne [Full Album]/06 - 06. Closer (Feat. Lester Duval).mp3": "232c28cb707b3be59f866c02a75e760f", - "Alfa Mist - Nocturne [Full Album]/07 - 07. Delusions: Rumination (Interlude) (Feat. Racheal Ofori).mp3": "2371a376778e5b34265db6b1a68a2c52", - "Alfa Mist - Nocturne [Full Album]/08 - 08. Dreams (Feat. Carmody).mp3": "a1fad1e44c847ff2c4ef385b15efac64", - "Alfa Mist - Nocturne [Full Album]/09 - 09. Dreaming (Interlude) (Feat. Racheal Ofori).mp3": "a60179ce5580943e7db8aad8251aa69e", - "Alfa Mist - Nocturne [Full Album]/10 - 10. Hopeful (Feat. Jordan Rakei).mp3": "f34d9b5efd737327b3b1484a59a49544", - "Alfa Mist - Nocturne [Full Album]/11 - 11. Sunrise (Pillows) (Feat. Emmavie).mp3": "88341b6f9164754151d54f504bed3eca", + "01. Intro (Feat. Racheal Ofori & Barney Artist).info.json": "6854df64b13eb93bc18fa8c69e3b0eac", + "02. Answers (Feat. Rick David & Kaya Thomas - Dyke).info.json": "2e0729ff647cdf58ad2d55d26962205c", + "03. Blaze (Feat. Kaya Thomas - Dyke).info.json": "2e813eef115551f01f779cdd88d37334", + "04. What If (Interlude).info.json": "536abb740383742a35e063b3b647123c", + "05. No Peace (Feat. Tom Misch).info.json": "c80246999d2fcbcfa4cffc7437cf1ce1", + "06. Closer (Feat. Lester Duval).info.json": "0e05dde4489f187e3ac92c7fd78b20ca", + "07. Delusions: Rumination (Interlude) (Feat. Racheal Ofori).info.json": "ff2c9ad8584b82567dc333666dae3722", + "08. Dreams (Feat. Carmody).info.json": "fc13e73715df025d23c439b08fb39ade", + "09. Dreaming (Interlude) (Feat. Racheal Ofori).info.json": "969395c8ff5123b99e521d0d1787f045", + "10. Hopeful (Feat. Jordan Rakei).info.json": "c00092731488ca50422522f9a84cc904", + "11. Sunrise (Pillows) (Feat. Emmavie).info.json": "67dde9a21cad1a9184187faa086a5162", + "Alfa Mist - Nocturne [Full Album]/01 - 01. Intro (Feat. Racheal Ofori & Barney Artist).mp3": "1ede8775719b99d05c89d6d0a2a74df5", + "Alfa Mist - Nocturne [Full Album]/02 - 02. Answers (Feat. Rick David & Kaya Thomas - Dyke).mp3": "2430b44a6c15050f7e2ee09274c26600", + "Alfa Mist - Nocturne [Full Album]/03 - 03. Blaze (Feat. Kaya Thomas - Dyke).mp3": "8dbb8d15109955c4540dfe3c015157b8", + "Alfa Mist - Nocturne [Full Album]/04 - 04. What If (Interlude).mp3": "69586c0b3de3f008f778da8b18c2eb6c", + "Alfa Mist - Nocturne [Full Album]/05 - 05. No Peace (Feat. Tom Misch).mp3": "3aab3f09e83fbb6f6c0ca8d40f890a39", + "Alfa Mist - Nocturne [Full Album]/06 - 06. Closer (Feat. Lester Duval).mp3": "66b195b766a977b25423bae8548a3182", + "Alfa Mist - Nocturne [Full Album]/07 - 07. Delusions: Rumination (Interlude) (Feat. Racheal Ofori).mp3": "f94199e76844bfc067acf6483db5bfe4", + "Alfa Mist - Nocturne [Full Album]/08 - 08. Dreams (Feat. Carmody).mp3": "7102f0ecdd2e00e48e469255e3f02524", + "Alfa Mist - Nocturne [Full Album]/09 - 09. Dreaming (Interlude) (Feat. Racheal Ofori).mp3": "655686323fd083b8ffc6956e1da7094f", + "Alfa Mist - Nocturne [Full Album]/10 - 10. Hopeful (Feat. Jordan Rakei).mp3": "68782c0b15ae4da60bae0cd8b2df1bed", + "Alfa Mist - Nocturne [Full Album]/11 - 11. Sunrise (Pillows) (Feat. Emmavie).mp3": "128edd880a9c63acfcdacfbe83596e46", "Alfa Mist - Nocturne [Full Album]/folder.jpg": "bd3685acc53072e591bae2505ecb0648" } \ No newline at end of file diff --git a/tests/resources/expected_downloads_summaries/plugins/split_by_chapters_with_regex_no_chapters_video_pass.txt b/tests/resources/expected_downloads_summaries/plugins/split_by_chapters_with_regex_no_chapters_video_pass.txt index 74418921..32e90ee7 100644 --- a/tests/resources/expected_downloads_summaries/plugins/split_by_chapters_with_regex_no_chapters_video_pass.txt +++ b/tests/resources/expected_downloads_summaries/plugins/split_by_chapters_with_regex_no_chapters_video_pass.txt @@ -1,5 +1,5 @@ { - "Oblivion Mod "Falcor" p.1.info.json": "5357a4ad737634396c577883ae586516", + "Oblivion Mod "Falcor" p.1.info.json": "f7f375e106ece9223a8c55a1e85b4a54", "Oblivion Mod "Falcor" p.1/01 - Oblivion Mod "Falcor" p.1.mp3": "703ffb93964ac025ee66221b98ee4d49", "Oblivion Mod "Falcor" p.1/folder.jpg": "fb95b510681676e81c321171fc23143e" } \ No newline at end of file diff --git a/tests/resources/expected_downloads_summaries/plugins/split_by_chapters_with_regex_video.json b/tests/resources/expected_downloads_summaries/plugins/split_by_chapters_with_regex_video.json index 5b574f9e..553f9773 100644 --- a/tests/resources/expected_downloads_summaries/plugins/split_by_chapters_with_regex_video.json +++ b/tests/resources/expected_downloads_summaries/plugins/split_by_chapters_with_regex_video.json @@ -1,25 +1,25 @@ { - "Answers (Feat. Rick David & Kaya Thomas - Dyke).info.json": "3cb3f1eec1813da1a09e2a2be0435fe3", - "Blaze (Feat. Kaya Thomas - Dyke).info.json": "a8600671c5c19683d405579185b51dbd", - "Closer (Feat. Lester Duval).info.json": "d46241bc3b6322838aa3634f5d4b74f4", - "Delusions: Rumination (Interlude) (Feat. Racheal Ofori).info.json": "fdeb58df8b9d55f7ddbb52fa3ac274d5", - "Dreaming (Interlude) (Feat. Racheal Ofori).info.json": "e3d5795ea6c596d6d97244daadf55fe9", - "Dreams (Feat. Carmody).info.json": "bcc5e14e8a25a62dfe6ab014a1eb98be", - "Hopeful (Feat. Jordan Rakei).info.json": "5643583ca640949f95d5e9ca135048aa", - "Intro (Feat. Racheal Ofori & Barney Artist).info.json": "49ef8e8555483a57773ce4573c9adbe9", - "No Peace (Feat. Tom Misch).info.json": "2ed45e531fdc46712dc6db1a8cc05f94", - "Nocturne/01 - Intro (Feat. Racheal Ofori & Barney Artist).mp3": "15157be58e0f72485de1e7e10961321f", - "Nocturne/02 - Answers (Feat. Rick David & Kaya Thomas - Dyke).mp3": "28ff5e2dda45771f1c6d5265dd03095e", - "Nocturne/03 - Blaze (Feat. Kaya Thomas - Dyke).mp3": "705d7fc1799c1a14aa0656bd6e2bf260", - "Nocturne/04 - What If (Interlude).mp3": "9fc7715a2eadec6303a2952cabc8047d", - "Nocturne/05 - No Peace (Feat. Tom Misch).mp3": "5c5ca334e214d5dabaa2d8788ed07675", - "Nocturne/06 - Closer (Feat. Lester Duval).mp3": "91208771580610afaa010dbe235c0556", - "Nocturne/07 - Delusions: Rumination (Interlude) (Feat. Racheal Ofori).mp3": "cc02d8ae63e7eb056d5354576cd6e718", - "Nocturne/08 - Dreams (Feat. Carmody).mp3": "bacdc9d1cf26ee0e3c0154785556a2e2", - "Nocturne/09 - Dreaming (Interlude) (Feat. Racheal Ofori).mp3": "cd213379cf53a8c1e4eb9134da257cd8", - "Nocturne/10 - Hopeful (Feat. Jordan Rakei).mp3": "ef7e06690ac849e1dd35771936d6ddb6", - "Nocturne/11 - Sunrise (Pillows) (Feat. Emmavie).mp3": "56293fb70edc1ef7decc2d417d87ff1d", + "Answers (Feat. Rick David & Kaya Thomas - Dyke).info.json": "71f1df2889daf7294941c92aa31ece37", + "Blaze (Feat. Kaya Thomas - Dyke).info.json": "3a3a80567daa571cd69179078b3583fb", + "Closer (Feat. Lester Duval).info.json": "ae6efcc14d6e2fcbe83de48d5e93e553", + "Delusions: Rumination (Interlude) (Feat. Racheal Ofori).info.json": "5e91665c20ebaf31e270ff16a1ac3dcd", + "Dreaming (Interlude) (Feat. Racheal Ofori).info.json": "4e8af5d5f3e42f0b84bba32bc4454e3d", + "Dreams (Feat. Carmody).info.json": "4763796e3e48c78003b394924de7a93d", + "Hopeful (Feat. Jordan Rakei).info.json": "0c934eaa9854fcb849b2dc160e9de7ac", + "Intro (Feat. Racheal Ofori & Barney Artist).info.json": "3e1a4aeb9f27904672a14603066e0ce9", + "No Peace (Feat. Tom Misch).info.json": "12c5cf1d442701b3ee18a1d3d250fc64", + "Nocturne/01 - Intro (Feat. Racheal Ofori & Barney Artist).mp3": "b2e2a9834f03d1928e0c8a0602899d4d", + "Nocturne/02 - Answers (Feat. Rick David & Kaya Thomas - Dyke).mp3": "8fe76edcc77c5d8db0f7b5b8577a4cf6", + "Nocturne/03 - Blaze (Feat. Kaya Thomas - Dyke).mp3": "fd45453753a783ec4f26ef399a8ecece", + "Nocturne/04 - What If (Interlude).mp3": "f30d081e7719f29c300e1830132e824e", + "Nocturne/05 - No Peace (Feat. Tom Misch).mp3": "878824c9d08add7f7525f11abd62670a", + "Nocturne/06 - Closer (Feat. Lester Duval).mp3": "bb5011399be2a68c9049f2e45fdf1331", + "Nocturne/07 - Delusions: Rumination (Interlude) (Feat. Racheal Ofori).mp3": "e8034ddb78455fe331d0bcdd0b6536fe", + "Nocturne/08 - Dreams (Feat. Carmody).mp3": "d1bae89f01d5028f0ae34ae41a9fbb17", + "Nocturne/09 - Dreaming (Interlude) (Feat. Racheal Ofori).mp3": "e50182fa81d56bb9261654e1906d18af", + "Nocturne/10 - Hopeful (Feat. Jordan Rakei).mp3": "d2f9958553262c4bee4f82f98f1d42c7", + "Nocturne/11 - Sunrise (Pillows) (Feat. Emmavie).mp3": "767dc4f27cc0a57d5391baf7b242d3f0", "Nocturne/folder.jpg": "bd3685acc53072e591bae2505ecb0648", - "Sunrise (Pillows) (Feat. Emmavie).info.json": "c2671abc8c942b8a6eac6f46f80be93f", - "What If (Interlude).info.json": "2df295486a3265b73979984f815f7983" + "Sunrise (Pillows) (Feat. Emmavie).info.json": "335efd1fc65c88ba8c7a3be803b1d84b", + "What If (Interlude).info.json": "2a91c79b4a938c2188a1a1912a3248ae" } \ No newline at end of file