From 32f1398d604f1f2df0f30c26c2a6bd98b8c542ab Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Fri, 13 Jan 2023 14:05:56 -0800 Subject: [PATCH] [BUGFIX] Fix playlist season thumbnails not appearing (#416) --- src/ytdl_sub/downloaders/downloader.py | 4 + tests/e2e/youtube/test_playlist.py | 21 +- .../youtube/test_playlist.json | 27 +-- .../youtube/test_playlist.txt | 218 +++++++++++++++--- 4 files changed, 220 insertions(+), 50 deletions(-) diff --git a/src/ytdl_sub/downloaders/downloader.py b/src/ytdl_sub/downloaders/downloader.py index 84fa9a6f..dc019ae1 100644 --- a/src/ytdl_sub/downloaders/downloader.py +++ b/src/ytdl_sub/downloaders/downloader.py @@ -45,6 +45,7 @@ from ytdl_sub.utils.file_handler import FileHandler from ytdl_sub.utils.file_handler import FileMetadata from ytdl_sub.utils.logger import Logger from ytdl_sub.utils.thumbnail import ThumbnailTypes +from ytdl_sub.utils.thumbnail import convert_download_thumbnail from ytdl_sub.utils.thumbnail import convert_url_thumbnail from ytdl_sub.validators.strict_dict_validator import StrictDictValidator from ytdl_sub.ytdl_additions.enhanced_download_archive import DownloadArchiver @@ -625,6 +626,9 @@ class Downloader(DownloadArchiver, Generic[DownloaderOptionsT], ABC): # If latest entry, always update the thumbnail on each entry if thumbnail_id == ThumbnailTypes.LATEST_ENTRY: + # Make sure the entry's thumbnail is converted to jpg + convert_download_thumbnail(entry, error_if_not_found=False) + # always save in dry-run even if it doesn't exist... if self.is_dry_run or os.path.isfile(entry.get_download_thumbnail_path()): self.save_file( diff --git a/tests/e2e/youtube/test_playlist.py b/tests/e2e/youtube/test_playlist.py index 658d5872..e2785951 100644 --- a/tests/e2e/youtube/test_playlist.py +++ b/tests/e2e/youtube/test_playlist.py @@ -11,13 +11,11 @@ from ytdl_sub.subscriptions.subscription import Subscription @pytest.fixture def playlist_preset_dict(output_directory): return { - "preset": "music_video", - "download": { - "url": "https://youtube.com/playlist?list=PL5BC0FC26BECA5A35", - "playlist_thumbnails": {"name": "poster.jpg", "uid": "latest_entry"}, - }, - # override the output directory with our fixture-generated dir - "output_options": {"output_directory": output_directory}, + "preset": [ + "jellyfin_tv_show_collection", + "season_by_collection__episode_by_year_month_day", + "collection_season_1", + ], # download the worst format so it is fast "ytdl_options": { "format": "worst[ext=mp4]", @@ -38,10 +36,15 @@ def playlist_preset_dict(output_directory): } }, "subtitles": { - "subtitles_name": "{music_video_name}.{lang}.{subtitles_ext}", + "subtitles_name": "{episode_file_path}.{lang}.{subtitles_ext}", "allow_auto_generated_subtitles": True, }, - "overrides": {"artist": "JMC"}, + "overrides": { + "tv_show_name": "JMC", + "tv_show_directory": output_directory, + "collection_season_1_url": "https://youtube.com/playlist?list=PL5BC0FC26BECA5A35", + "collection_season_1_name": "JMC - Season 1", + }, } diff --git a/tests/resources/expected_downloads_summaries/youtube/test_playlist.json b/tests/resources/expected_downloads_summaries/youtube/test_playlist.json index e6b6803a..e580bf5c 100644 --- a/tests/resources/expected_downloads_summaries/youtube/test_playlist.json +++ b/tests/resources/expected_downloads_summaries/youtube/test_playlist.json @@ -1,17 +1,14 @@ { - ".ytdl-sub-music_video_playlist_test-download-archive.json": "e7f7c35e33c132a96d1f12b18f388b35", - "JMC/JMC - Jesse's Minecraft Server [Trailer - Feb.1]-thumb.jpg": "b232d253df621aa770b780c1301d364d", - "JMC/JMC - Jesse's Minecraft Server [Trailer - Feb.1].info.json": "c719512a82647a676fa04d388c837e03", - "JMC/JMC - Jesse's Minecraft Server [Trailer - Feb.1].mp4": "7bfa1475504a7c8a4aaa8c89f9306331", - "JMC/JMC - Jesse's Minecraft Server [Trailer - Feb.1].nfo": "de6f9a17a5ebf92aa02b14f7342b8d36", - "JMC/JMC - Jesse's Minecraft Server [Trailer - Feb.27]-thumb.jpg": "d17c379ea8b362f5b97c6b213b0342cb", - "JMC/JMC - Jesse's Minecraft Server [Trailer - Feb.27].info.json": "d450357aa6856b11d079f1f11bbd92c5", - "JMC/JMC - Jesse's Minecraft Server [Trailer - Feb.27].mp4": "04ab5cb3cc12325d0c96a7cd04a8b91d", - "JMC/JMC - Jesse's Minecraft Server [Trailer - Feb.27].nfo": "9a4a57bb91f1ac97b588fdf66bac4c9b", - "JMC/JMC - Jesse's Minecraft Server [Trailer - Mar.21]-thumb.jpg": "e7830aa8a64b0cde65ba3f7e5fc56530", - "JMC/JMC - Jesse's Minecraft Server [Trailer - Mar.21].info.json": "8fdf1c054a6b335e9624690e08a33f1c", - "JMC/JMC - Jesse's Minecraft Server [Trailer - Mar.21].mp4": "025de6099a5c98e6397153c7a62d517d", - "JMC/JMC - Jesse's Minecraft Server [Trailer - Mar.21].nfo": "b98f1fa3e76b4592aeeaed4f6e220809", - "poster.jpg": "e7830aa8a64b0cde65ba3f7e5fc56530", - "tvshow.nfo": "e4123860532466ed5e0ebf2c9e44eb18" + "JMC/.ytdl-sub-music_video_playlist_test-download-archive.json": "8c8c22bd8a9206fa0b3c9f2eff9827fc", + "JMC/Season 01/s01.e11020101 - 0SVukUyys10-thumb.jpg": "b232d253df621aa770b780c1301d364d", + "JMC/Season 01/s01.e11020101 - 0SVukUyys10.mp4": "95f3abaabccdd76461be5dace92e9489", + "JMC/Season 01/s01.e11020101 - 0SVukUyys10.nfo": "d0f2d843b091834c62ccf33e2d2e700f", + "JMC/Season 01/s01.e11022701 - qPybBrXspds-thumb.jpg": "d17c379ea8b362f5b97c6b213b0342cb", + "JMC/Season 01/s01.e11022701 - qPybBrXspds.mp4": "5465a5e5712351945e98667006b08747", + "JMC/Season 01/s01.e11022701 - qPybBrXspds.nfo": "7b230eb8560735cc3ca9598b7b1b2cb7", + "JMC/Season 01/s01.e11032101 - DBjFvs6HafU-thumb.jpg": "e7830aa8a64b0cde65ba3f7e5fc56530", + "JMC/Season 01/s01.e11032101 - DBjFvs6HafU.mp4": "c79ed62c72feb49bd02595322c6e1b89", + "JMC/Season 01/s01.e11032101 - DBjFvs6HafU.nfo": "a0d7fd6752ca56fe4206c4c711b5765d", + "JMC/season01-poster.jpg": "e7830aa8a64b0cde65ba3f7e5fc56530", + "JMC/tvshow.nfo": "f7892df46b4176dde645e23b8a4b653e" } \ No newline at end of file diff --git a/tests/resources/transaction_log_summaries/youtube/test_playlist.txt b/tests/resources/transaction_log_summaries/youtube/test_playlist.txt index 64f9caff..aa7eeb65 100644 --- a/tests/resources/transaction_log_summaries/youtube/test_playlist.txt +++ b/tests/resources/transaction_log_summaries/youtube/test_playlist.txt @@ -2,47 +2,213 @@ Files created: ---------------------------------------- {output_directory} .ytdl-sub-music_video_playlist_test-download-archive.json - poster.jpg + season01-poster.jpg tvshow.nfo NFO tags: test: + genre: ytdl-sub + namedseason: + attributes: + number: 1 + tag: JMC - Season 1 playlist_description: Trailers, Updates, etc playlist_title: Jesse's Minecraft Server playlist_uploader: Project Zombie -{output_directory}/JMC - JMC - Jesse's Minecraft Server [Trailer - Feb.1]-thumb.jpg - JMC - Jesse's Minecraft Server [Trailer - Feb.1].info.json - JMC - Jesse's Minecraft Server [Trailer - Feb.1].mp4 - JMC - Jesse's Minecraft Server [Trailer - Feb.1].nfo + title: JMC +{output_directory}/Season 01 + s01.e11020101 - 0SVukUyys10-thumb.jpg + s01.e11020101 - 0SVukUyys10.mp4 + Video Tags: + date: 2011-02-01 + episode_id: 11020101 + genre: ytdl-sub + show: JMC + synopsis: + https://www.youtube.com/watch?v=0SVukUyys10 + + To join the server, you must apply at: + http://www.jesseminecraft.webs.com/ + + This is just a brief video of the server as of Feb. 1, 2011. + + Texture Pack I Use: + http://www.minecraftforum.net/viewtopic.php?f=25&t=29164 + title: 2011-02-01 - Jesse's Minecraft Server [Trailer - Feb.1] + year: 2011 + s01.e11020101 - 0SVukUyys10.nfo NFO tags: - musicvideo: - album: Music Videos - artist: JMC + episodedetails: + aired: 2011-02-01 + episode: 11020101 + genre: ytdl-sub playlist_count: 3 playlist_index: 3 - title: Jesse's Minecraft Server [Trailer - Feb.1] + plot: + https://www.youtube.com/watch?v=0SVukUyys10 + + To join the server, you must apply at: + http://www.jesseminecraft.webs.com/ + + This is just a brief video of the server as of Feb. 1, 2011. + + Texture Pack I Use: + http://www.minecraftforum.net/viewtopic.php?f=25&t=29164 + season: 1 + title: 2011-02-01 - Jesse's Minecraft Server [Trailer - Feb.1] year: 2011 - JMC - Jesse's Minecraft Server [Trailer - Feb.27]-thumb.jpg - JMC - Jesse's Minecraft Server [Trailer - Feb.27].info.json - JMC - Jesse's Minecraft Server [Trailer - Feb.27].mp4 - JMC - Jesse's Minecraft Server [Trailer - Feb.27].nfo + s01.e11022701 - qPybBrXspds-thumb.jpg + s01.e11022701 - qPybBrXspds.mp4 + Video Tags: + date: 2011-02-27 + episode_id: 11022701 + genre: ytdl-sub + show: JMC + synopsis: + https://www.youtube.com/watch?v=qPybBrXspds + + Website Link: + http://jesseminecraft.webs.com/ + + All you have to do is read the rules, and fill out a quick, little application to join the Server so we know you read them. We do this to keep the griefers/newbs out, it only takes three minutes, it's not that big of a deal. + + Jesse's Minecraft Server is a City Roleplay/Survival Server, there is a currency, public transportation, strict rules for immersive gameplay, and has a decent size population. Over 750 people have logged onto the server. It is very important you read the rules, we don't tolerate idiots. + + There are over 200 empty properties that are ready for anyone to own! Join now! + + This is the server state as of Feb. 27, 2011. + ---------------------------------------------------------------------------------- + + Texture Pack: + http://www.minecraftforum.net/viewtopic.php?f=25&t=29164 + + Recording Software: + http://www.fraps.com/download.php + + Video Editing Software: + http://explore.live.com/windows-live-movie-maker?os=other + + Song: + Given to Fly - Pearl Jam + (Off of the 'Yield' album) + + I claim no ownership of this song, all the credit goes to Pearl Jam and their producers. + title: 2011-02-27 - Jesse's Minecraft Server [Trailer - Feb.27] + year: 2011 + s01.e11022701 - qPybBrXspds.nfo NFO tags: - musicvideo: - album: Music Videos - artist: JMC + episodedetails: + aired: 2011-02-27 + episode: 11022701 + genre: ytdl-sub playlist_count: 3 playlist_index: 2 - title: Jesse's Minecraft Server [Trailer - Feb.27] + plot: + https://www.youtube.com/watch?v=qPybBrXspds + + Website Link: + http://jesseminecraft.webs.com/ + + All you have to do is read the rules, and fill out a quick, little application to join the Server so we know you read them. We do this to keep the griefers/newbs out, it only takes three minutes, it's not that big of a deal. + + Jesse's Minecraft Server is a City Roleplay/Survival Server, there is a currency, public transportation, strict rules for immersive gameplay, and has a decent size population. Over 750 people have logged onto the server. It is very important you read the rules, we don't tolerate idiots. + + There are over 200 empty properties that are ready for anyone to own! Join now! + + This is the server state as of Feb. 27, 2011. + ---------------------------------------------------------------------------------- + + Texture Pack: + http://www.minecraftforum.net/viewtopic.php?f=25&t=29164 + + Recording Software: + http://www.fraps.com/download.php + + Video Editing Software: + http://explore.live.com/windows-live-movie-maker?os=other + + Song: + Given to Fly - Pearl Jam + (Off of the 'Yield' album) + + I claim no ownership of this song, all the credit goes to Pearl Jam and their producers. + season: 1 + title: 2011-02-27 - Jesse's Minecraft Server [Trailer - Feb.27] year: 2011 - JMC - Jesse's Minecraft Server [Trailer - Mar.21]-thumb.jpg - JMC - Jesse's Minecraft Server [Trailer - Mar.21].info.json - JMC - Jesse's Minecraft Server [Trailer - Mar.21].mp4 - JMC - Jesse's Minecraft Server [Trailer - Mar.21].nfo + s01.e11032101 - DBjFvs6HafU-thumb.jpg + s01.e11032101 - DBjFvs6HafU.mp4 + Video Tags: + date: 2011-03-21 + episode_id: 11032101 + genre: ytdl-sub + show: JMC + synopsis: + https://www.youtube.com/watch?v=DBjFvs6HafU + + Website Link: + http://jesseminecraft.webs.com/ + + To get on the whitelist, please look at the website linked above (^^^). Due to the overwhelming amount of people trying to join, I've made it so it costs $2 to become a member through paypal. All of it is explained on the website. + + Jesse's Minecraft Server is a City Roleplay/Survival Server, there is a currency, public transportation, strict rules for immersive gameplay, and has a decent size population. Over 1000 people have logged onto the server. It is very important you read the rules, we don't tolerate idiots. + + There are over 300 empty properties that are ready for anyone to own! Join now! + + This is the server state as of Mar. 21, 2011. + --------------------------------------------------------------------------------­-- + + Texture Pack: + http://www.minecraftforum.net/viewtopic.php?f=25&t=29164 + + Recording Software: + http://www.fraps.com/download.php + + Video Editing Software: + http://explore.live.com/windows-live-movie-maker?os=other + + Song: + Indifference - Pearl Jam + (Off of the 'Vs.' album) + + I claim no ownership of this song, all the credit goes to Pearl Jam and their producers. + title: 2011-03-21 - Jesse's Minecraft Server [Trailer - Mar.21] + year: 2011 + s01.e11032101 - DBjFvs6HafU.nfo NFO tags: - musicvideo: - album: Music Videos - artist: JMC + episodedetails: + aired: 2011-03-21 + episode: 11032101 + genre: ytdl-sub playlist_count: 3 playlist_index: 1 - title: Jesse's Minecraft Server [Trailer - Mar.21] + plot: + https://www.youtube.com/watch?v=DBjFvs6HafU + + Website Link: + http://jesseminecraft.webs.com/ + + To get on the whitelist, please look at the website linked above (^^^). Due to the overwhelming amount of people trying to join, I've made it so it costs $2 to become a member through paypal. All of it is explained on the website. + + Jesse's Minecraft Server is a City Roleplay/Survival Server, there is a currency, public transportation, strict rules for immersive gameplay, and has a decent size population. Over 1000 people have logged onto the server. It is very important you read the rules, we don't tolerate idiots. + + There are over 300 empty properties that are ready for anyone to own! Join now! + + This is the server state as of Mar. 21, 2011. + --------------------------------------------------------------------------------­-- + + Texture Pack: + http://www.minecraftforum.net/viewtopic.php?f=25&t=29164 + + Recording Software: + http://www.fraps.com/download.php + + Video Editing Software: + http://explore.live.com/windows-live-movie-maker?os=other + + Song: + Indifference - Pearl Jam + (Off of the 'Vs.' album) + + I claim no ownership of this song, all the credit goes to Pearl Jam and their producers. + season: 1 + title: 2011-03-21 - Jesse's Minecraft Server [Trailer - Mar.21] year: 2011 \ No newline at end of file