@@ -236,9 +236,17 @@ def v2_model(self) -> SongModelV2:
236236
237237class YtmusicWatchPlaylistSong (YtmusicSearchSong ):
238238 year : str # This field exists in get_watch_playlist API.
239+ length : str # watch playlist uses `length` instead of `duration`.
240+ watch_thumbnail : List [SearchNestedThumbnail ] = Field (
241+ default_factory = list , alias = "thumbnail"
242+ ) # watch playlist uses singular key.
239243
240244 def v2_model (self ) -> SongModelV2 :
241245 song = super ().v2_model ()
246+ if song .duration <= 0 and self .length :
247+ song .duration = int (timeparse (self .length ) * 1000 )
248+ if not song .pic_url and self .watch_thumbnail :
249+ song .pic_url = self .watch_thumbnail [- 1 ].url or ""
242250 song .date = self .year or ""
243251 return song
244252
@@ -418,18 +426,6 @@ def v2_model(self, identifier) -> ArtistModelV2:
418426 # Note that the channelId is different from the identifier.
419427 # Though the channelId also refers to the artist,
420428 # it's songs is a empty list.
421- album_count = - 1
422- if self .albums and self .albums .browseId is None :
423- album_count = len (self .albums .results or [])
424-
425- song_count = - 1
426- if self .songs and self .songs .browseId is None :
427- song_count = len (self .songs .results or [])
428-
429- mv_count = - 1
430- if self .videos and self .videos .browseId is None :
431- mv_count = len (self .videos .results or [])
432-
433429 return ArtistModelV2 (
434430 identifier = identifier ,
435431 source = self .source ,
@@ -441,9 +437,9 @@ def v2_model(self, identifier) -> ArtistModelV2:
441437 for song in (self .songs .results if self .songs else []) or []
442438 ],
443439 description = self .description or "" ,
444- song_count = song_count ,
445- album_count = album_count ,
446- mv_count = mv_count ,
440+ song_count = - 1 ,
441+ album_count = - 1 ,
442+ mv_count = - 1 ,
447443 )
448444
449445
@@ -525,12 +521,6 @@ class Format(BaseModel):
525521 videoDetails : VideoDetails
526522 streamingData : StreamingData
527523
528- def get_pic_url (self ) -> str :
529- thumbnails = self .videoDetails .thumbnail if self .videoDetails else None
530- if thumbnails is None :
531- return ""
532- return thumbnails .cover or ""
533-
534524 def list_formats (self ) -> List [Quality .Audio ]:
535525 qualities = set ()
536526 if self .streamingData is None :
0 commit comments