feat: caught age restricted exception
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
207ca1b6a5
commit
72531f0bee
@ -552,7 +552,12 @@ class YoutubeMusic(SuperYouTube):
|
|||||||
return self.download_values_by_url[source.url]
|
return self.download_values_by_url[source.url]
|
||||||
|
|
||||||
if ydl_res is None:
|
if ydl_res is None:
|
||||||
ydl_res = self.ydl.extract_info(url=source.url, download=False)
|
try:
|
||||||
|
ydl_res = self.ydl.extract_info(url=source.url, download=False)
|
||||||
|
except DownloadError as e:
|
||||||
|
self.not_download[source.hash_url] = e
|
||||||
|
self.LOGGER.error(f"Couldn't fetch song from {source.url}. {e}")
|
||||||
|
return {"error": e}
|
||||||
_best_format = _get_best_format(ydl_res.get("formats", [{}]))
|
_best_format = _get_best_format(ydl_res.get("formats", [{}]))
|
||||||
|
|
||||||
self.download_values_by_url[source.url] = {
|
self.download_values_by_url[source.url] = {
|
||||||
@ -567,7 +572,7 @@ class YoutubeMusic(SuperYouTube):
|
|||||||
def download_song_to_target(self, source: Source, target: Target, desc: str = None) -> DownloadResult:
|
def download_song_to_target(self, source: Source, target: Target, desc: str = None) -> DownloadResult:
|
||||||
media = self.fetch_media_url(source)
|
media = self.fetch_media_url(source)
|
||||||
|
|
||||||
if source.hash_url not in self.not_download:
|
if source.hash_url not in self.not_download and "error" not in media:
|
||||||
result = self.download_connection.stream_into(
|
result = self.download_connection.stream_into(
|
||||||
media["url"],
|
media["url"],
|
||||||
target,
|
target,
|
||||||
@ -580,7 +585,7 @@ class YoutubeMusic(SuperYouTube):
|
|||||||
method="GET",
|
method="GET",
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
result = DownloadResult(error_message=str(self.not_download[source.hash_url]))
|
result = DownloadResult(error_message=str(media.get("error") or self.not_download[source.hash_url]))
|
||||||
|
|
||||||
if result.is_fatal_error:
|
if result.is_fatal_error:
|
||||||
result.merge(super().download_song_to_target(source=source, target=target, desc=desc))
|
result.merge(super().download_song_to_target(source=source, target=target, desc=desc))
|
||||||
|
Loading…
Reference in New Issue
Block a user