[FEATURE] Add webpage_url source variable (#224)
This commit is contained in:
parent
f24860c729
commit
4b6c79caef
6 changed files with 27 additions and 5 deletions
|
|
@ -147,7 +147,7 @@ class SoundcloudAlbumsAndSinglesDownloader(
|
|||
if not self.is_dry_run:
|
||||
_ = self.extract_info_with_retry(
|
||||
is_downloaded_fn=track.is_downloaded,
|
||||
url=album.kwargs("webpage_url"),
|
||||
url=album.webpage_url,
|
||||
ytdl_options_overrides={
|
||||
"playlist_items": str(track.kwargs("playlist_index")),
|
||||
"writeinfojson": False,
|
||||
|
|
@ -177,7 +177,7 @@ class SoundcloudAlbumsAndSinglesDownloader(
|
|||
if not self.is_dry_run:
|
||||
_ = self.extract_info_with_retry(
|
||||
is_downloaded_fn=track.is_downloaded,
|
||||
url=track.kwargs("webpage_url"),
|
||||
url=track.webpage_url,
|
||||
ytdl_options_overrides={"writeinfojson": False},
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ class YoutubeChannelDownloader(YoutubeDownloader[YoutubeChannelDownloaderOptions
|
|||
as_single_video_dict = self.extract_info_with_retry(
|
||||
is_downloaded_fn=None if self.is_dry_run else video.is_downloaded,
|
||||
ytdl_options_overrides={"writeinfojson": False, "skip_download": self.is_dry_run},
|
||||
url=video.kwargs("webpage_url"),
|
||||
url=video.webpage_url,
|
||||
)
|
||||
|
||||
# Workaround for the ytdlp issue
|
||||
|
|
|
|||
|
|
@ -141,6 +141,8 @@ class YoutubeMergePlaylistDownloader(
|
|||
if "requested_downloads" in entry_dict
|
||||
else "mkv"
|
||||
)
|
||||
entry_dict["webpage_url"] = self.download_options.playlist_url
|
||||
|
||||
return YoutubeVideo(entry_dict=entry_dict, working_directory=self.working_directory)
|
||||
|
||||
def download(self) -> List[Tuple[YoutubeVideo, FileMetadata]]:
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ class YoutubePlaylistDownloader(
|
|||
as_single_video_dict = self.extract_info_with_retry(
|
||||
is_downloaded_fn=None if self.is_dry_run else video.is_downloaded,
|
||||
ytdl_options_overrides={"writeinfojson": False, "skip_download": self.is_dry_run},
|
||||
url=video.kwargs("webpage_url"),
|
||||
url=video.webpage_url,
|
||||
)
|
||||
|
||||
# Workaround for the ytdlp issue
|
||||
|
|
|
|||
|
|
@ -99,6 +99,16 @@ class EntryVariables(SourceVariables):
|
|||
"""
|
||||
return sanitize_filename(self.title)
|
||||
|
||||
@property
|
||||
def webpage_url(self: BaseEntry) -> str:
|
||||
"""
|
||||
Returns
|
||||
-------
|
||||
str
|
||||
The url to the webpage.
|
||||
"""
|
||||
return self.kwargs("webpage_url")
|
||||
|
||||
@property
|
||||
def ext(self: BaseEntry) -> str:
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -34,6 +34,11 @@ def thumbnail_ext():
|
|||
return "jpg"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def webpage_url() -> str:
|
||||
return "https://yourname.here"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def download_thumbnail_name(uid, thumbnail_ext):
|
||||
return f"{uid}.{thumbnail_ext}"
|
||||
|
|
@ -52,6 +57,7 @@ def mock_entry_to_dict(
|
|||
extractor,
|
||||
upload_date,
|
||||
thumbnail_ext,
|
||||
webpage_url,
|
||||
):
|
||||
return {
|
||||
"uid": uid,
|
||||
|
|
@ -78,11 +84,14 @@ def mock_entry_to_dict(
|
|||
"upload_day_of_year_reversed_padded": "354",
|
||||
"thumbnail_ext": thumbnail_ext,
|
||||
"info_json_ext": "info.json",
|
||||
"webpage_url": webpage_url,
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_entry_kwargs(uid, title, ext, upload_date, extractor, download_thumbnail_name):
|
||||
def mock_entry_kwargs(
|
||||
uid, title, ext, upload_date, extractor, download_thumbnail_name, webpage_url
|
||||
):
|
||||
return {
|
||||
"id": uid,
|
||||
"extractor": extractor,
|
||||
|
|
@ -90,6 +99,7 @@ def mock_entry_kwargs(uid, title, ext, upload_date, extractor, download_thumbnai
|
|||
"ext": ext,
|
||||
"upload_date": upload_date,
|
||||
"thumbnail": download_thumbnail_name,
|
||||
"webpage_url": webpage_url,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue