[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:
|
if not self.is_dry_run:
|
||||||
_ = self.extract_info_with_retry(
|
_ = self.extract_info_with_retry(
|
||||||
is_downloaded_fn=track.is_downloaded,
|
is_downloaded_fn=track.is_downloaded,
|
||||||
url=album.kwargs("webpage_url"),
|
url=album.webpage_url,
|
||||||
ytdl_options_overrides={
|
ytdl_options_overrides={
|
||||||
"playlist_items": str(track.kwargs("playlist_index")),
|
"playlist_items": str(track.kwargs("playlist_index")),
|
||||||
"writeinfojson": False,
|
"writeinfojson": False,
|
||||||
|
|
@ -177,7 +177,7 @@ class SoundcloudAlbumsAndSinglesDownloader(
|
||||||
if not self.is_dry_run:
|
if not self.is_dry_run:
|
||||||
_ = self.extract_info_with_retry(
|
_ = self.extract_info_with_retry(
|
||||||
is_downloaded_fn=track.is_downloaded,
|
is_downloaded_fn=track.is_downloaded,
|
||||||
url=track.kwargs("webpage_url"),
|
url=track.webpage_url,
|
||||||
ytdl_options_overrides={"writeinfojson": False},
|
ytdl_options_overrides={"writeinfojson": False},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -214,7 +214,7 @@ class YoutubeChannelDownloader(YoutubeDownloader[YoutubeChannelDownloaderOptions
|
||||||
as_single_video_dict = self.extract_info_with_retry(
|
as_single_video_dict = self.extract_info_with_retry(
|
||||||
is_downloaded_fn=None if self.is_dry_run else video.is_downloaded,
|
is_downloaded_fn=None if self.is_dry_run else video.is_downloaded,
|
||||||
ytdl_options_overrides={"writeinfojson": False, "skip_download": self.is_dry_run},
|
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
|
# Workaround for the ytdlp issue
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,8 @@ class YoutubeMergePlaylistDownloader(
|
||||||
if "requested_downloads" in entry_dict
|
if "requested_downloads" in entry_dict
|
||||||
else "mkv"
|
else "mkv"
|
||||||
)
|
)
|
||||||
|
entry_dict["webpage_url"] = self.download_options.playlist_url
|
||||||
|
|
||||||
return YoutubeVideo(entry_dict=entry_dict, working_directory=self.working_directory)
|
return YoutubeVideo(entry_dict=entry_dict, working_directory=self.working_directory)
|
||||||
|
|
||||||
def download(self) -> List[Tuple[YoutubeVideo, FileMetadata]]:
|
def download(self) -> List[Tuple[YoutubeVideo, FileMetadata]]:
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ class YoutubePlaylistDownloader(
|
||||||
as_single_video_dict = self.extract_info_with_retry(
|
as_single_video_dict = self.extract_info_with_retry(
|
||||||
is_downloaded_fn=None if self.is_dry_run else video.is_downloaded,
|
is_downloaded_fn=None if self.is_dry_run else video.is_downloaded,
|
||||||
ytdl_options_overrides={"writeinfojson": False, "skip_download": self.is_dry_run},
|
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
|
# Workaround for the ytdlp issue
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,16 @@ class EntryVariables(SourceVariables):
|
||||||
"""
|
"""
|
||||||
return sanitize_filename(self.title)
|
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
|
@property
|
||||||
def ext(self: BaseEntry) -> str:
|
def ext(self: BaseEntry) -> str:
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,11 @@ def thumbnail_ext():
|
||||||
return "jpg"
|
return "jpg"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def webpage_url() -> str:
|
||||||
|
return "https://yourname.here"
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def download_thumbnail_name(uid, thumbnail_ext):
|
def download_thumbnail_name(uid, thumbnail_ext):
|
||||||
return f"{uid}.{thumbnail_ext}"
|
return f"{uid}.{thumbnail_ext}"
|
||||||
|
|
@ -52,6 +57,7 @@ def mock_entry_to_dict(
|
||||||
extractor,
|
extractor,
|
||||||
upload_date,
|
upload_date,
|
||||||
thumbnail_ext,
|
thumbnail_ext,
|
||||||
|
webpage_url,
|
||||||
):
|
):
|
||||||
return {
|
return {
|
||||||
"uid": uid,
|
"uid": uid,
|
||||||
|
|
@ -78,11 +84,14 @@ def mock_entry_to_dict(
|
||||||
"upload_day_of_year_reversed_padded": "354",
|
"upload_day_of_year_reversed_padded": "354",
|
||||||
"thumbnail_ext": thumbnail_ext,
|
"thumbnail_ext": thumbnail_ext,
|
||||||
"info_json_ext": "info.json",
|
"info_json_ext": "info.json",
|
||||||
|
"webpage_url": webpage_url,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@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 {
|
return {
|
||||||
"id": uid,
|
"id": uid,
|
||||||
"extractor": extractor,
|
"extractor": extractor,
|
||||||
|
|
@ -90,6 +99,7 @@ def mock_entry_kwargs(uid, title, ext, upload_date, extractor, download_thumbnai
|
||||||
"ext": ext,
|
"ext": ext,
|
||||||
"upload_date": upload_date,
|
"upload_date": upload_date,
|
||||||
"thumbnail": download_thumbnail_name,
|
"thumbnail": download_thumbnail_name,
|
||||||
|
"webpage_url": webpage_url,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue