feat: added additional data
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
90d685da81
commit
5ed902489f
@ -60,7 +60,7 @@ def get_collection_string(
|
||||
def get_element_str(element) -> str:
|
||||
nonlocal add_id
|
||||
r = element.title_string.strip()
|
||||
if add_id:
|
||||
if add_id and False:
|
||||
r += " " + str(element.id)
|
||||
return r
|
||||
|
||||
|
@ -538,6 +538,10 @@ class YoutubeMusic(SuperYouTube):
|
||||
for renderer in renderer_list:
|
||||
album.add_list_of_other_objects(parse_renderer(renderer))
|
||||
|
||||
for song in album.song_collection:
|
||||
for song_source in song.source_collection:
|
||||
song_source.additional_data["playlist_id"] = browse_id
|
||||
|
||||
return album
|
||||
|
||||
|
||||
@ -556,10 +560,7 @@ class YoutubeMusic(SuperYouTube):
|
||||
uploader = ydl_res.get("uploader", "")
|
||||
if uploader.endswith(" - Topic"):
|
||||
artist_names = [uploader.rstrip(" - Topic")]
|
||||
"""
|
||||
elif "artist" in ydl_res:
|
||||
artist_names = ydl_res.get("artist").split(", ")
|
||||
"""
|
||||
|
||||
artist_list = [
|
||||
Artist(
|
||||
name=name,
|
||||
@ -577,7 +578,7 @@ class YoutubeMusic(SuperYouTube):
|
||||
))
|
||||
|
||||
artist_name = artist_names[0] if len(artist_names) > 0 else None
|
||||
return Song(
|
||||
song = Song(
|
||||
title=ydl_res.get("track", clean_song_title(ydl_res.get("title"), artist_name=artist_name)),
|
||||
note=ydl_res.get("descriptions"),
|
||||
album_list=album_list,
|
||||
@ -590,6 +591,41 @@ class YoutubeMusic(SuperYouTube):
|
||||
), source],
|
||||
)
|
||||
|
||||
# other song details
|
||||
parsed_url = urlparse(source.url)
|
||||
browse_id = parse_qs(parsed_url.query)['v'][0]
|
||||
request_data = {
|
||||
"captionParams": {},
|
||||
"context": {**self.credentials.context, "adSignalsInfo": {"params": []}},
|
||||
"videoId": browse_id,
|
||||
}
|
||||
if "playlist_id" in source.additional_data:
|
||||
request_data["playlistId"] = source.additional_data["playlist_id"]
|
||||
|
||||
initial_details = self.yt_music_connection.post(
|
||||
url=get_youtube_url(path="/youtubei/v1/player", query=f"prettyPrint=false"),
|
||||
json=request_data,
|
||||
name=f"fetch_album_{browse_id}.json",
|
||||
)
|
||||
|
||||
if initial_details is None:
|
||||
return song
|
||||
|
||||
dump_to_file(f"fetch_song_{browse_id}.json", initial_details.text, is_json=True, exit_after_dump=False)
|
||||
|
||||
data = initial_details.json()
|
||||
video_details = data.get("videoDetails", {})
|
||||
|
||||
browse_id = video_details.get("videoId", browse_id)
|
||||
song.title = video_details.get("title", song.title)
|
||||
if video_details.get("isLiveContent", False):
|
||||
for album in song.album_list:
|
||||
album.album_type = AlbumType.LIVE_ALBUM
|
||||
for thumbnail in video_details.get("thumbnails", []):
|
||||
song.artwork.append(**thumbnail)
|
||||
|
||||
return song
|
||||
|
||||
|
||||
def fetch_media_url(self, source: Source, ydl_res: dict = None) -> dict:
|
||||
def _get_best_format(format_list: List[Dict]) -> dict:
|
||||
|
@ -15,7 +15,7 @@ __stage__ = os.getenv("STAGE", "prod")
|
||||
DEBUG = (__stage__ == "dev") and True
|
||||
DEBUG_LOGGING = DEBUG and False
|
||||
DEBUG_TRACE = DEBUG and True
|
||||
DEBUG_OBJECT_TRACE = DEBUG and True
|
||||
DEBUG_OBJECT_TRACE = DEBUG and False
|
||||
DEBUG_OBJECT_TRACE_CALLSTACK = DEBUG_OBJECT_TRACE and False
|
||||
DEBUG_YOUTUBE_INITIALIZING = DEBUG and False
|
||||
DEBUG_PAGES = DEBUG and False
|
||||
|
Loading…
Reference in New Issue
Block a user