[BACKEND] Expose raw playlist index

This commit is contained in:
Jesse Bannon 2022-09-25 10:55:39 -07:00
parent 3d0ade1141
commit c29b5b6a3e
11 changed files with 84 additions and 83 deletions

View file

@ -5,7 +5,7 @@ from ytdl_sub.downloaders.generic.collection_validator import CollectionValidato
from ytdl_sub.downloaders.youtube.abc import YoutubeDownloader
from ytdl_sub.downloaders.youtube.abc import YoutubeDownloaderOptions
from ytdl_sub.entries.entry_parent import EntryParent
from ytdl_sub.entries.youtube import YoutubePlaylistVideo
from ytdl_sub.entries.youtube import YoutubeVideo
from ytdl_sub.validators.url_validator import YoutubePlaylistUrlValidator
@ -51,10 +51,10 @@ class YoutubePlaylistDownloaderOptions(YoutubeDownloaderOptions):
class YoutubePlaylistDownloader(
YoutubeDownloader[YoutubePlaylistDownloaderOptions, YoutubePlaylistVideo]
YoutubeDownloader[YoutubePlaylistDownloaderOptions, YoutubeVideo]
):
downloader_options_type = YoutubePlaylistDownloaderOptions
downloader_entry_type = YoutubePlaylistVideo
downloader_entry_type = YoutubeVideo
# pylint: disable=line-too-long
@classmethod
@ -81,9 +81,9 @@ class YoutubePlaylistDownloader(
assert len(self.parents) == 1, "Playlist should be the only entry parent"
return self.parents[0]
def download(self) -> Generator[YoutubePlaylistVideo, None, None]:
def download(self) -> Generator[YoutubeVideo, None, None]:
"""
Downloads all videos in a Youtube playlist.
"""
for entry in super().download():
yield entry.to_type(YoutubePlaylistVideo)
yield entry.to_type(YoutubeVideo)

View file

@ -73,24 +73,3 @@ class YoutubeVideoVariables(EntryVariables):
"""
return sanitize_filename(self.artist)
@property
def playlist_index(self) -> int:
"""
Returns
-------
int
The index of the video in the playlist. For non-playlist download strategies, this will
always return 1.
"""
return 1
@property
def playlist_size(self) -> int:
"""
Returns
-------
int
The size of the playlist. For non-playlist download strategies, this will always return
1.
"""
return 1

View file

@ -21,23 +21,3 @@ class YoutubeVideo(YoutubeVideoVariables, Entry):
if os.path.isfile(mkv_file_path):
return "mkv"
return super().ext
class YoutubePlaylistVideo(YoutubeVideo):
@property
def playlist_index(self) -> int:
"""
Returns
-------
The playlist index
"""
return self.kwargs("playlist_index")
@property
def playlist_size(self) -> int:
"""
Returns
-------
The size of the playlist
"""
return self.kwargs("playlist_count")

View file

@ -204,7 +204,7 @@ class SplitByChaptersPlugin(Plugin[SplitByChaptersOptions]):
/ f"{new_uid}.{entry.thumbnail_ext}",
)
# Format the split video as a YoutubePlaylistVideo
# Format the split video
split_videos_and_metadata.append(
self._create_split_entry(
source_entry=entry,

View file

@ -1,54 +1,54 @@
{
".ytdl-sub-pz-download-archive.json": "70615451318cdb5e018e007c77893a39",
"Season 2010/s2010.e0813 - Oblivion Mod Falcor p.1-thumb.jpg": "fb95b510681676e81c321171fc23143e",
"Season 2010/s2010.e0813 - Oblivion Mod Falcor p.1.info.json": "321813dd5598303d5fc91c7aa302f1b5",
"Season 2010/s2010.e0813 - Oblivion Mod Falcor p.1.info.json": "5d0c1e9a569e30b16f92410aabd340ee",
"Season 2010/s2010.e0813 - Oblivion Mod Falcor p.1.mp4": "931a705864c57d21d6fedebed4af6bbc",
"Season 2010/s2010.e0813 - Oblivion Mod Falcor p.1.nfo": "2d0738094d8e649eaebbab16fd647da1",
"Season 2010/s2010.e0813 - Oblivion Mod Falcor p.1.nfo": "a71a34a60c67b939a38c2c342df0c436",
"Season 2010/s2010.e1202 - Oblivion Mod Falcor p.2-thumb.jpg": "8b32ee9c037fa669e444a0ac181525a1",
"Season 2010/s2010.e1202 - Oblivion Mod Falcor p.2.info.json": "461c98e86a4c3848fd89671a78900131",
"Season 2010/s2010.e1202 - Oblivion Mod Falcor p.2.mp4": "d3469b4dca7139cb3dbc38712b6796bf",
"Season 2010/s2010.e1202 - Oblivion Mod Falcor p.2.nfo": "5c258f9e54854ef292ce3c58331da110",
"Season 2010/s2010.e1202 - Oblivion Mod Falcor p.2.info.json": "21131c4b4708ea7f77648cf98f3ef4e3",
"Season 2010/s2010.e1202 - Oblivion Mod Falcor p.2.mp4": "157ae6e2ce0b36bca1cfea943e461f80",
"Season 2010/s2010.e1202 - Oblivion Mod Falcor p.2.nfo": "5dd3914f929f1a06e9020ddfdf31cacf",
"Season 2011/s2011.e0201 - Jesse's Minecraft Server [Trailer - Feb.1]-thumb.jpg": "b232d253df621aa770b780c1301d364d",
"Season 2011/s2011.e0201 - Jesse's Minecraft Server [Trailer - Feb.1].info.json": "ccb88e48fa500e74f7a51fcac5d4934d",
"Season 2011/s2011.e0201 - Jesse's Minecraft Server [Trailer - Feb.1].info.json": "3732cdb30f6e3b8203a632aaa77f193d",
"Season 2011/s2011.e0201 - Jesse's Minecraft Server [Trailer - Feb.1].mp4": "e66287b9832277b6a4d1554e29d9fdcc",
"Season 2011/s2011.e0201 - Jesse's Minecraft Server [Trailer - Feb.1].nfo": "abb3ac33366cc3b86d0467c8fb80a323",
"Season 2011/s2011.e0201 - Jesse's Minecraft Server [Trailer - Feb.1].nfo": "4eb6ba6910aa5f930625c2a955330051",
"Season 2011/s2011.e0227 - Jesse's Minecraft Server [Trailer - Feb.27]-thumb.jpg": "d17c379ea8b362f5b97c6b213b0342cb",
"Season 2011/s2011.e0227 - Jesse's Minecraft Server [Trailer - Feb.27].info.json": "157d3cb2fdb0f47d924fbab5a07bbe9e",
"Season 2011/s2011.e0227 - Jesse's Minecraft Server [Trailer - Feb.27].info.json": "ff471ef617781b57069585ec1484f478",
"Season 2011/s2011.e0227 - Jesse's Minecraft Server [Trailer - Feb.27].mp4": "04ab5cb3cc12325d0c96a7cd04a8b91d",
"Season 2011/s2011.e0227 - Jesse's Minecraft Server [Trailer - Feb.27].nfo": "46190954652c9d9812e061fc0c9e1d92",
"Season 2011/s2011.e0227 - Jesse's Minecraft Server [Trailer - Feb.27].nfo": "2a4a319266f3b672f409c29983390404",
"Season 2011/s2011.e0321 - Jesse's Minecraft Server [Trailer - Mar.21]-thumb.jpg": "e7830aa8a64b0cde65ba3f7e5fc56530",
"Season 2011/s2011.e0321 - Jesse's Minecraft Server [Trailer - Mar.21].info.json": "9660710f3aab66cbfaaa485eac55db13",
"Season 2011/s2011.e0321 - Jesse's Minecraft Server [Trailer - Mar.21].info.json": "bdc4bc467c9409fc2ba10aba731bbbec",
"Season 2011/s2011.e0321 - Jesse's Minecraft Server [Trailer - Mar.21].mp4": "025de6099a5c98e6397153c7a62d517d",
"Season 2011/s2011.e0321 - Jesse's Minecraft Server [Trailer - Mar.21].nfo": "30993fa8e00a0e370b4db244f3da8f7d",
"Season 2011/s2011.e0321 - Jesse's Minecraft Server [Trailer - Mar.21].nfo": "cb65c7a45d81444e7bfc5d2e64f4423d",
"Season 2011/s2011.e0529 - Project Zombie Official Trailer (IP mc.projectzombie.beastnode.net)-thumb.jpg": "c956192a379b3661595c9920972d4819",
"Season 2011/s2011.e0529 - Project Zombie Official Trailer (IP mc.projectzombie.beastnode.net).info.json": "d43ca09cff753e13c4d4badaad8b8cf3",
"Season 2011/s2011.e0529 - Project Zombie Official Trailer (IP mc.projectzombie.beastnode.net).info.json": "e7319581afcdec1cfc5c42ffe20053b7",
"Season 2011/s2011.e0529 - Project Zombie Official Trailer (IP mc.projectzombie.beastnode.net).mp4": "3d9c19835b03355d6fd5d00cd59dbe5b",
"Season 2011/s2011.e0529 - Project Zombie Official Trailer (IP mc.projectzombie.beastnode.net).nfo": "11a0e8754c414875bcd454358683da5f",
"Season 2011/s2011.e0529 - Project Zombie Official Trailer (IP mc.projectzombie.beastnode.net).nfo": "99e8f5da8ebb7bfbe6a27799465a39c0",
"Season 2011/s2011.e0630 - Project Zombie Fin-thumb.jpg": "00ed383591779ffe98291de60f198fe9",
"Season 2011/s2011.e0630 - Project Zombie Fin.info.json": "351c14be8af8b7811515533f778252af",
"Season 2011/s2011.e0630 - Project Zombie Fin.info.json": "616ed2e1cee91373502397028161ff8d",
"Season 2011/s2011.e0630 - Project Zombie Fin.mp4": "4971cb2d4fa29460361031f3fa8e1ea9",
"Season 2011/s2011.e0630 - Project Zombie Fin.nfo": "a464b9c8c48a9a5d4776436d8108f8f5",
"Season 2011/s2011.e0630 - Project Zombie Fin.nfo": "7d751a80d3a2dec151602514278998c7",
"Season 2011/s2011.e1121 - Skyrim 'Ultra HD wMods' [PC]-thumb.jpg": "1718599d5189c65f7d8cf6acfa5ea851",
"Season 2011/s2011.e1121 - Skyrim 'Ultra HD wMods' [PC].info.json": "a46366e7be54d3cb755a8a2994a55d3e",
"Season 2011/s2011.e1121 - Skyrim 'Ultra HD wMods' [PC].info.json": "2ec37d87b73784e9b5188909eef32541",
"Season 2011/s2011.e1121 - Skyrim 'Ultra HD wMods' [PC].mp4": "55e9b0add08c48c9c66105da0def2426",
"Season 2011/s2011.e1121 - Skyrim 'Ultra HD wMods' [PC].nfo": "3562934ab9a5e802d955eda24ad355de",
"Season 2011/s2011.e1121 - Skyrim 'Ultra HD wMods' [PC].nfo": "40f104e94e69648ffe692137a9523412",
"Season 2012/s2012.e0123 - Project Zombie Map Trailer-thumb.jpg": "54ebe9df801b278fdd17b21afa8373a6",
"Season 2012/s2012.e0123 - Project Zombie Map Trailer.info.json": "64857d41adcad52bf97611e4fcae292d",
"Season 2012/s2012.e0123 - Project Zombie Map Trailer.info.json": "f1c5feaa81a7771927c1697294870a80",
"Season 2012/s2012.e0123 - Project Zombie Map Trailer.mp4": "65e4ce53ed5ec4139995469f99477a50",
"Season 2012/s2012.e0123 - Project Zombie Map Trailer.nfo": "5e810d839be90dab579400a6177f90b3",
"Season 2012/s2012.e0123 - Project Zombie Map Trailer.nfo": "552328911403e2f8092d10b53ac44680",
"Season 2013/s2013.e0719 - Project Zombie Rewind Trailer-thumb.jpg": "e29d49433175de8a761af35c5307791f",
"Season 2013/s2013.e0719 - Project Zombie Rewind Trailer.info.json": "8d18bb9557625b910dd044f158969d05",
"Season 2013/s2013.e0719 - Project Zombie Rewind Trailer.info.json": "ed830b4d20cffecab81e95134469a82a",
"Season 2013/s2013.e0719 - Project Zombie Rewind Trailer.mp4": "18620a8257a686beda65e54add4d4cd1",
"Season 2013/s2013.e0719 - Project Zombie Rewind Trailer.nfo": "83772bec917bb5d71e1ca0c061c1ec78",
"Season 2013/s2013.e0719 - Project Zombie Rewind Trailer.nfo": "bcb859f3ba37eafa902cd470bfa600c2",
"Season 2018/s2018.e1029 - Jesse's Minecraft Server Teaser Trailer-thumb.jpg": "705ca4e0d99b37e9ecdf6bfe4b90c59b",
"Season 2018/s2018.e1029 - Jesse's Minecraft Server Teaser Trailer.info.json": "d9088a723ce5445c88bf72cb5a39b933",
"Season 2018/s2018.e1029 - Jesse's Minecraft Server Teaser Trailer.info.json": "8c4c941e1251f49498d60d977b04b744",
"Season 2018/s2018.e1029 - Jesse's Minecraft Server Teaser Trailer.mp4": "82f6ee7253e1dbb83ae7215af08ffacc",
"Season 2018/s2018.e1029 - Jesse's Minecraft Server Teaser Trailer.nfo": "368d68db0cbe9eb4f43ece0517445e82",
"Season 2018/s2018.e1029 - Jesse's Minecraft Server Teaser Trailer.nfo": "c07d29f2f98ac674dffbcd1e55c860ff",
"Season 2018/s2018.e1102 - Jesse's Minecraft Server IP mc.jesse.id-thumb.jpg": "28d852ede73b879b9ebf9a061cfc7d46",
"Season 2018/s2018.e1102 - Jesse's Minecraft Server IP mc.jesse.id.en.srt": "3d2c4e7f65d2ca5e96da38ce7eecfc4e",
"Season 2018/s2018.e1102 - Jesse's Minecraft Server IP mc.jesse.id.info.json": "7907cf957d8de4d4036af60d686061f5",
"Season 2018/s2018.e1102 - Jesse's Minecraft Server IP mc.jesse.id.info.json": "64148d293c2dac43268ff48e83929ed7",
"Season 2018/s2018.e1102 - Jesse's Minecraft Server IP mc.jesse.id.mp4": "e733b4cc385b953b08c8eb0f47e03c1e",
"Season 2018/s2018.e1102 - Jesse's Minecraft Server IP mc.jesse.id.nfo": "d9114d43d87907b2afc06eb089a8ac0a",
"Season 2018/s2018.e1102 - Jesse's Minecraft Server IP mc.jesse.id.nfo": "0a7aa028f2acf0380d00ce32bf72199a",
"fanart.jpg": "129c6639b47299bc48062f0365e670ee",
"poster.jpg": "5de28eea5a921a041452ab3ce1041f73",
"tvshow.nfo": "d516b5b125e3a16cdee641045a1a1990"

View file

@ -1,16 +1,16 @@
{
".ytdl-sub-music_video_playlist_test-download-archive.json": "25b8e44961343116436584e341c7fe9b",
"JMC - Jesse's Minecraft Server [Trailer - Feb.1]-thumb.jpg": "b232d253df621aa770b780c1301d364d",
"JMC - Jesse's Minecraft Server [Trailer - Feb.1].info.json": "a1763e5afb49be0935d932334336f62f",
"JMC - Jesse's Minecraft Server [Trailer - Feb.1].info.json": "a5858026c9cb2149760b9e18ac3ee91e",
"JMC - Jesse's Minecraft Server [Trailer - Feb.1].mp4": "e66287b9832277b6a4d1554e29d9fdcc",
"JMC - Jesse's Minecraft Server [Trailer - Feb.1].nfo": "f8fd72bb97ed03938487494ad9094ca0",
"JMC - Jesse's Minecraft Server [Trailer - Feb.1].nfo": "de6f9a17a5ebf92aa02b14f7342b8d36",
"JMC - Jesse's Minecraft Server [Trailer - Feb.27]-thumb.jpg": "d17c379ea8b362f5b97c6b213b0342cb",
"JMC - Jesse's Minecraft Server [Trailer - Feb.27].info.json": "2d3b4299450776edd822514d071671a4",
"JMC - Jesse's Minecraft Server [Trailer - Feb.27].info.json": "1d0e20b597d15d2e9373b879f416d9db",
"JMC - Jesse's Minecraft Server [Trailer - Feb.27].mp4": "04ab5cb3cc12325d0c96a7cd04a8b91d",
"JMC - Jesse's Minecraft Server [Trailer - Feb.27].nfo": "6de4d997cfb300356072b4ebb09cbe38",
"JMC - Jesse's Minecraft Server [Trailer - Feb.27].nfo": "9a4a57bb91f1ac97b588fdf66bac4c9b",
"JMC - Jesse's Minecraft Server [Trailer - Mar.21]-thumb.jpg": "e7830aa8a64b0cde65ba3f7e5fc56530",
"JMC - Jesse's Minecraft Server [Trailer - Mar.21].info.json": "17a942919cb951d7cfd0dcc502bf4499",
"JMC - Jesse's Minecraft Server [Trailer - Mar.21].info.json": "d998a4c3d7f22742cf016336addb8c55",
"JMC - Jesse's Minecraft Server [Trailer - Mar.21].mp4": "025de6099a5c98e6397153c7a62d517d",
"JMC - Jesse's Minecraft Server [Trailer - Mar.21].nfo": "f000a6ed8caacb62a134a6ca81e3f308",
"JMC - Jesse's Minecraft Server [Trailer - Mar.21].nfo": "b98f1fa3e76b4592aeeaed4f6e220809",
"tvshow.nfo": "792b0594defdfd6642086b76fcc6a91b"
}

View file

@ -9,6 +9,8 @@ Season 2010/s2010.e0813 - Oblivion Mod Falcor p.1.nfo
episodedetails:
aired: 2010-08-13
episode: 813
playlist_count: 13
playlist_index: 13
plot:
PLEASE WATCH IN HD!
@ -27,6 +29,8 @@ Season 2010/s2010.e1202 - Oblivion Mod Falcor p.2.nfo
episodedetails:
aired: 2010-12-02
episode: 1202
playlist_count: 13
playlist_index: 12
plot:
PLEASE WATCH IN HD.
@ -45,6 +49,8 @@ Season 2011/s2011.e0201 - Jesse's Minecraft Server [Trailer - Feb.1].nfo
episodedetails:
aired: 2011-02-01
episode: 201
playlist_count: 13
playlist_index: 11
plot:
To join the server, you must apply at:
http://www.jesseminecraft.webs.com/
@ -64,6 +70,8 @@ Season 2011/s2011.e0227 - Jesse's Minecraft Server [Trailer - Feb.27].nfo
episodedetails:
aired: 2011-02-27
episode: 227
playlist_count: 13
playlist_index: 10
plot:
Website Link:
http://jesseminecraft.webs.com/
@ -102,6 +110,8 @@ Season 2011/s2011.e0321 - Jesse's Minecraft Server [Trailer - Mar.21].nfo
episodedetails:
aired: 2011-03-21
episode: 321
playlist_count: 13
playlist_index: 9
plot:
Website Link:
http://jesseminecraft.webs.com/
@ -140,6 +150,8 @@ Season 2011/s2011.e0529 - Project Zombie Official Trailer (IP mc.projec
episodedetails:
aired: 2011-05-29
episode: 529
playlist_count: 13
playlist_index: 8
plot:
Currently in alpha testing.
http://www.projectzombie.net/
@ -168,6 +180,8 @@ Season 2011/s2011.e0630 - Project Zombie Fin.nfo
episodedetails:
aired: 2011-06-30
episode: 630
playlist_count: 13
playlist_index: 7
plot:
Twas a good run while it lasted. If you're still interested in playing PZ, you can join my Roleplay Server, yes, Project Zombie is completely imported onto that one:
http://www.jesseminecraft.webs.com/
@ -182,6 +196,8 @@ Season 2011/s2011.e1121 - Skyrim 'Ultra HD wMods' [PC].nfo
episodedetails:
aired: 2011-11-21
episode: 1121
playlist_count: 13
playlist_index: 6
plot:
Mods I have used:
http://skyrimnexus.com/downloads/file.php?id=329
@ -203,6 +219,8 @@ Season 2012/s2012.e0123 - Project Zombie Map Trailer.nfo
episodedetails:
aired: 2012-01-23
episode: 123
playlist_count: 13
playlist_index: 4
plot:
Faction Server IP: 72.9.157.88:25652
Project Zombie IP: mc.projectzombie.beastnode.net
@ -224,6 +242,8 @@ Season 2013/s2013.e0719 - Project Zombie Rewind Trailer.nfo
episodedetails:
aired: 2013-07-19
episode: 719
playlist_count: 13
playlist_index: 3
plot:
IP: 172.245.24.118
http://www.projectzombie.net/
@ -240,6 +260,8 @@ Season 2018/s2018.e1029 - Jesse's Minecraft Server Teaser Trailer.nfo
episodedetails:
aired: 2018-10-29
episode: 1029
playlist_count: 13
playlist_index: 2
plot:
See the full trailer here: https://youtu.be/LN2e6idGluI
Discord: https://discord.gg/BQN7SSe
@ -262,6 +284,8 @@ Season 2018/s2018.e1102 - Jesse's Minecraft Server IP mc.jesse.id.nfo
episodedetails:
aired: 2018-11-02
episode: 1102
playlist_count: 13
playlist_index: 1
plot:
IP: mc.jesse.id
Live Map: http://mc.jesse.id:8123

View file

@ -9,6 +9,8 @@ JMC - Jesse's Minecraft Server [Trailer - Feb.1].nfo
musicvideo:
album: Music Videos
artist: JMC
playlist_count: 3
playlist_index: 3
title: Jesse's Minecraft Server [Trailer - Feb.1]
year: 2011
JMC - Jesse's Minecraft Server [Trailer - Feb.27]-thumb.jpg
@ -19,6 +21,8 @@ JMC - Jesse's Minecraft Server [Trailer - Feb.27].nfo
musicvideo:
album: Music Videos
artist: JMC
playlist_count: 3
playlist_index: 2
title: Jesse's Minecraft Server [Trailer - Feb.27]
year: 2011
JMC - Jesse's Minecraft Server [Trailer - Mar.21]-thumb.jpg
@ -29,6 +33,8 @@ JMC - Jesse's Minecraft Server [Trailer - Mar.21].nfo
musicvideo:
album: Music Videos
artist: JMC
playlist_count: 3
playlist_index: 1
title: Jesse's Minecraft Server [Trailer - Mar.21]
year: 2011
tvshow.nfo

View file

@ -26,6 +26,12 @@ def channel_preset_dict(output_directory):
"subtitles_name": "{episode_name}.{lang}.{subtitles_ext}",
"allow_auto_generated_subtitles": True,
},
"nfo_tags": {
"tags": {
"playlist_index": "{playlist_index}",
"playlist_count": "{playlist_count}",
}
},
"output_directory_nfo_tags": {
"tags": {
"source_uploader": "{source_uploader}",

View file

@ -28,6 +28,12 @@ def playlist_preset_dict(output_directory):
"source_description": "{source_description}",
},
},
"nfo_tags": {
"tags": {
"playlist_index": "{playlist_index}",
"playlist_count": "{playlist_count}",
}
},
"subtitles": {
"subtitles_name": "{music_video_name}.{lang}.{subtitles_ext}",
"allow_auto_generated_subtitles": True,

View file

@ -10,7 +10,7 @@ def playlist_index():
@pytest.fixture
def playlist_size():
def playlist_count():
return 1
@ -31,13 +31,13 @@ def artist():
@pytest.fixture
def mock_youtube_video_to_dict(
mock_entry_to_dict, playlist_index, playlist_size, channel, track_title, artist
mock_entry_to_dict, playlist_index, playlist_count, channel, track_title, artist
):
return dict(
mock_entry_to_dict,
**{
"playlist_index": playlist_index,
"playlist_size": playlist_size,
"playlist_count": playlist_count,
"channel": channel,
"channel_sanitized": channel,
"track_title": track_title,
@ -50,13 +50,13 @@ def mock_youtube_video_to_dict(
@pytest.fixture
def mock_youtube_video_kwargs(
mock_entry_kwargs, playlist_index, playlist_size, channel, track_title, artist
mock_entry_kwargs, playlist_index, playlist_count, channel, track_title, artist
):
return dict(
mock_entry_kwargs,
**{
"playlist_index": playlist_index,
"playlist_count": playlist_size,
"playlist_count": playlist_count,
"channel": channel,
"track": track_title,
"artist": artist,