getting close
This commit is contained in:
parent
09816fb384
commit
bbed76fb7c
5 changed files with 109 additions and 21 deletions
|
|
@ -459,18 +459,11 @@ class MultiUrlDownloader(SourcePlugin[MultiUrlValidator]):
|
|||
):
|
||||
yield orphan
|
||||
|
||||
def _download_metadata(self, url: str, is_bilateral: bool) -> Iterable[Entry]:
|
||||
def _download_metadata(self, url: str) -> Iterable[Entry]:
|
||||
metadata_ytdl_options = self.metadata_ytdl_options(url=url)
|
||||
download_reversed = ScriptUtils.bool_formatter_output(
|
||||
self.overrides.apply_formatter(self._collection_url_mapping[url].download_reverse)
|
||||
)
|
||||
if is_bilateral:
|
||||
# If bilateral metadata scrape, inverse to download the other side
|
||||
metadata_ytdl_options = dict(
|
||||
metadata_ytdl_options,
|
||||
**{"playlistreverse": not metadata_ytdl_options.get("playlistreverse", False)},
|
||||
)
|
||||
download_reversed = not download_reversed
|
||||
|
||||
parents, orphan_entries = self._download_url_metadata(
|
||||
url=url,
|
||||
|
|
@ -483,11 +476,7 @@ class MultiUrlDownloader(SourcePlugin[MultiUrlValidator]):
|
|||
entries_total=sum(parent.num_children() for parent in parents) + len(orphan_entries)
|
||||
)
|
||||
|
||||
if is_bilateral:
|
||||
download_logger.info("Beginning downloads for %s in the opposite direction", url)
|
||||
else:
|
||||
download_logger.info("Beginning downloads for %s", url)
|
||||
|
||||
download_logger.info("Beginning downloads for %s", url)
|
||||
for entry in self._iterate_entries(
|
||||
parents=parents,
|
||||
orphans=orphan_entries,
|
||||
|
|
@ -504,15 +493,9 @@ class MultiUrlDownloader(SourcePlugin[MultiUrlValidator]):
|
|||
if not (url := self.overrides.apply_formatter(collection_url.url)):
|
||||
continue
|
||||
|
||||
for entry in self._download_metadata(url=url, is_bilateral=False):
|
||||
for entry in self._download_metadata(url=url):
|
||||
yield entry
|
||||
|
||||
if ScriptUtils.bool_formatter_output(
|
||||
self.overrides.apply_formatter(collection_url.extract_bilaterally)
|
||||
):
|
||||
for entry in self._download_metadata(url=url, is_bilateral=True):
|
||||
yield entry
|
||||
|
||||
def download(self, entry: Entry) -> Optional[Entry]:
|
||||
"""
|
||||
Parameters
|
||||
|
|
|
|||
|
|
@ -51,6 +51,20 @@ def playlist_preset_dict(output_directory):
|
|||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def playlist_bilateral_dict(output_directory):
|
||||
return {
|
||||
"preset": [
|
||||
"Jellyfin TV Show by Date",
|
||||
],
|
||||
"format": "worst[ext=mp4]",
|
||||
"overrides": {
|
||||
"url": "https://www.youtube.com/playlist?list=PLd4Q7G88JqoekF0b30NYQcOTnTiIe9Ali",
|
||||
"tv_show_directory": output_directory,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class TestPlaylist:
|
||||
"""
|
||||
Downloads my old minecraft youtube channel, pretends they are music videos. Ensure the above
|
||||
|
|
@ -222,3 +236,41 @@ class TestPlaylist:
|
|||
|
||||
assert len(subscriptions) == 1
|
||||
assert subscriptions[0].transaction_log.is_empty
|
||||
|
||||
def test_tv_show_downloads_bilateral(
|
||||
self,
|
||||
playlist_bilateral_dict: Dict,
|
||||
output_directory: str,
|
||||
default_config: ConfigFile,
|
||||
):
|
||||
playlist_bilateral_dict['filter_include'] = [
|
||||
"{ %contains(title, 'Feb.1') }"
|
||||
]
|
||||
playlist_subscription = Subscription.from_dict(
|
||||
config=default_config,
|
||||
preset_name="bilateral_test",
|
||||
preset_dict=playlist_bilateral_dict,
|
||||
)
|
||||
|
||||
transaction_log = playlist_subscription.download(dry_run=False)
|
||||
assert_transaction_log_matches(
|
||||
output_directory=output_directory,
|
||||
transaction_log=transaction_log,
|
||||
transaction_log_summary_file_name="youtube/test_playlist_bilateral_p1.txt",
|
||||
)
|
||||
|
||||
# Now that one vid is downloaded, attempt to download all and see if bilateral
|
||||
# logic kicks in
|
||||
del playlist_bilateral_dict['filter_include']
|
||||
playlist_subscription = Subscription.from_dict(
|
||||
config=default_config,
|
||||
preset_name="bilateral_test",
|
||||
preset_dict=playlist_bilateral_dict,
|
||||
)
|
||||
|
||||
transaction_log = playlist_subscription.download(dry_run=True)
|
||||
assert_transaction_log_matches(
|
||||
output_directory=output_directory,
|
||||
transaction_log=transaction_log,
|
||||
transaction_log_summary_file_name="youtube/test_playlist_bilateral_p2.txt",
|
||||
)
|
||||
|
|
@ -2,7 +2,7 @@ import os
|
|||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
REGENERATE_FIXTURES: bool = False
|
||||
REGENERATE_FIXTURES: bool = True
|
||||
|
||||
RESOURCE_PATH: Path = Path("tests") / "resources"
|
||||
_FILE_FIXTURE_PATH: Path = RESOURCE_PATH / "file_fixtures"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
Files created:
|
||||
----------------------------------------
|
||||
{output_directory}
|
||||
.ytdl-sub-bilateral_test-download-archive.json
|
||||
tvshow.nfo
|
||||
NFO tags:
|
||||
tvshow:
|
||||
genre: ytdl-sub
|
||||
mpaa: TV-14
|
||||
title: bilateral_test
|
||||
{output_directory}/Season 2011
|
||||
s2011.e020101 - Jesse's Minecraft Server [Trailer - Feb.1]-thumb.jpg
|
||||
s2011.e020101 - Jesse's Minecraft Server [Trailer - Feb.1].info.json
|
||||
s2011.e020101 - Jesse's Minecraft Server [Trailer - Feb.1].mp4
|
||||
Video Tags:
|
||||
contentRating: TV-14
|
||||
date: 2011-02-01
|
||||
episode_id: 20101
|
||||
genre: ytdl-sub
|
||||
show: bilateral_test
|
||||
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
|
||||
s2011.e020101 - Jesse's Minecraft Server [Trailer - Feb.1].nfo
|
||||
NFO tags:
|
||||
episodedetails:
|
||||
aired: 2011-02-01
|
||||
episode: 20101
|
||||
genre: ytdl-sub
|
||||
mpaa: TV-14
|
||||
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: 2011
|
||||
title: 2011-02-01 - Jesse's Minecraft Server [Trailer - Feb.1]
|
||||
year: 2011
|
||||
|
|
@ -0,0 +1 @@
|
|||
No new, modified, or removed files in '{output_directory}'
|
||||
Loading…
Reference in a new issue