working?
This commit is contained in:
parent
6494f8199b
commit
9b8c79beee
4 changed files with 20 additions and 49 deletions
|
|
@ -529,6 +529,10 @@ class Downloader(DownloadArchiver, Generic[DownloaderOptionsT, DownloaderEntryT]
|
|||
thumbnail_name = self.overrides.apply_formatter(thumbnail_info.name, entry=entry)
|
||||
thumbnail_id = self.overrides.apply_formatter(thumbnail_info.uid)
|
||||
|
||||
# alread downloaded
|
||||
if thumbnail_name in thumbnails_downloaded:
|
||||
continue
|
||||
|
||||
if (thumbnail_url := parent.get_thumbnail_url(thumbnail_id=thumbnail_id)) is None:
|
||||
download_logger.warning("TODO: Failed to download channel's avatar image")
|
||||
continue
|
||||
|
|
@ -574,10 +578,3 @@ class Downloader(DownloadArchiver, Generic[DownloaderOptionsT, DownloaderEntryT]
|
|||
entry.kwargs(SOURCE_ENTRY), working_directory=self.working_directory
|
||||
),
|
||||
)
|
||||
|
||||
def post_download(self):
|
||||
"""
|
||||
After all media entries have been downloaded, post processed, and moved to the output
|
||||
directory, run this function. This lets the downloader add any extra files directly to the
|
||||
output directory, for things like YT channel image, banner.
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
from typing import Dict, List
|
||||
from typing import Dict
|
||||
from typing import Generator
|
||||
from typing import List
|
||||
from typing import Optional
|
||||
|
||||
from ytdl_sub.downloaders.generic.collection_validator import CollectionValidator
|
||||
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 YoutubeVideo
|
||||
from ytdl_sub.validators.string_formatter_validators import OverridesStringFormatterValidator
|
||||
from ytdl_sub.validators.url_validator import YoutubeChannelUrlValidator
|
||||
|
|
@ -53,25 +53,23 @@ class YoutubeChannelDownloaderOptions(YoutubeDownloaderOptions):
|
|||
"""Download from the channel url"""
|
||||
playlist_thumbnails: List[Dict] = []
|
||||
if self._channel_avatar_path:
|
||||
playlist_thumbnails.append({
|
||||
"name": self._channel_avatar_path.format_string,
|
||||
"uid": "avatar_uncropped",
|
||||
})
|
||||
playlist_thumbnails.append(
|
||||
{
|
||||
"name": self._channel_avatar_path.format_string,
|
||||
"uid": "avatar_uncropped",
|
||||
}
|
||||
)
|
||||
if self._channel_banner_path:
|
||||
playlist_thumbnails.append({
|
||||
"name": self._channel_banner_path.format_string,
|
||||
"uid": "banner_uncropped",
|
||||
})
|
||||
playlist_thumbnails.append(
|
||||
{
|
||||
"name": self._channel_banner_path.format_string,
|
||||
"uid": "banner_uncropped",
|
||||
}
|
||||
)
|
||||
|
||||
return CollectionValidator(
|
||||
name=self._name,
|
||||
value={
|
||||
"urls": [
|
||||
{
|
||||
"url": self.channel_url,
|
||||
"playlist_thumbnails": playlist_thumbnails
|
||||
}
|
||||
]},
|
||||
value={"urls": [{"url": self.channel_url, "playlist_thumbnails": playlist_thumbnails}]},
|
||||
)
|
||||
|
||||
@property
|
||||
|
|
@ -125,12 +123,6 @@ class YoutubeChannelDownloader(YoutubeDownloader[YoutubeChannelDownloaderOptions
|
|||
|
||||
# pylint: enable=line-too-long
|
||||
|
||||
@property
|
||||
def channel(self) -> EntryParent:
|
||||
"""Gets the channel entry parent"""
|
||||
assert len(self.parents) == 1, "Channel should be the only entry parent"
|
||||
return self.parents[0]
|
||||
|
||||
def download(self) -> Generator[YoutubeVideo, None, None]:
|
||||
"""
|
||||
Downloads all videos from a channel
|
||||
|
|
|
|||
|
|
@ -265,7 +265,6 @@ class SubscriptionDownload(BaseSubscription, ABC):
|
|||
plugins=plugins, dry_run=dry_run, entry=entry, entry_metadata=entry_metadata
|
||||
)
|
||||
|
||||
downloader.post_download()
|
||||
for plugin in plugins:
|
||||
plugin.post_process_subscription()
|
||||
|
||||
|
|
|
|||
|
|
@ -63,20 +63,3 @@ class TestChannelAsKodiTvShow:
|
|||
dry_run=dry_run,
|
||||
expected_download_summary_file_name="youtube/test_channel_full.json",
|
||||
)
|
||||
|
||||
def test_channel_post_download(self, channel_as_tv_show_config, channel_preset_dict):
|
||||
channel_preset_dict["ytdl_options"]["max_views"] = 1 # no downloads occur
|
||||
full_channel_subscription = Subscription.from_dict(
|
||||
config=channel_as_tv_show_config, preset_name="pz", preset_dict=channel_preset_dict
|
||||
)
|
||||
|
||||
with assert_debug_log( # Ensure retry debug message is thrown
|
||||
logger=retry_logger,
|
||||
expected_message="Exception thrown when attempting to run %s, attempt %d of %d",
|
||||
), patch( # Make sleeps instant
|
||||
"ytdl_sub.utils.retry.sleep"
|
||||
), patch( # Mock error when calling urlopen
|
||||
"ytdl_sub.utils.thumbnail.urlopen"
|
||||
) as mock_urlopen:
|
||||
mock_urlopen.side_effect = [Exception("error")]
|
||||
full_channel_subscription.download(dry_run=True)
|
||||
|
|
|
|||
Loading…
Reference in a new issue