get_watch_playlist: fixed an issue when longBylineText is missing
This commit is contained in:
parent
c8af65d643
commit
cc26a63264
3 changed files with 16 additions and 9 deletions
|
|
@ -5,8 +5,8 @@ import pytest
|
|||
|
||||
class TestBrowsing:
|
||||
def test_get_home(self, yt, yt_auth):
|
||||
result = yt.get_home(limit=6)
|
||||
assert len(result) >= 6
|
||||
result = yt.get_home()
|
||||
assert len(result) == 2
|
||||
result = yt_auth.get_home(limit=15)
|
||||
assert len(result) >= 15
|
||||
|
||||
|
|
|
|||
|
|
@ -29,15 +29,21 @@ def populate_account():
|
|||
|
||||
# add some albums, which also populates songs and artists as a side effect
|
||||
unique_albums = set(track["album"]["id"] for track in yt_playlist["tracks"])
|
||||
playlist_ids = [yt_brand.get_album(album)["audioPlaylistId"] for album in unique_albums if album]
|
||||
albums = [yt_brand.get_album(album) for album in unique_albums if album]
|
||||
playlist_ids = [album["audioPlaylistId"] for album in albums]
|
||||
for playlist_id in playlist_ids:
|
||||
print(f"Adding album {playlist_id}")
|
||||
yt_brand.rate_playlist(playlist_id, "LIKE")
|
||||
|
||||
# like some songs
|
||||
for track in yt_playlist["tracks"]:
|
||||
print(f"liking track {track['videoId']}")
|
||||
yt_brand.rate_song(track["videoId"], "LIKE")
|
||||
videoIds = list(
|
||||
set(
|
||||
track["videoId"] for track in itertools.chain.from_iterable([album["tracks"] for album in albums])
|
||||
)
|
||||
)
|
||||
for videoId in videoIds[:200]:
|
||||
print(f"Liking track {videoId}")
|
||||
yt_brand.rate_song(videoId, "LIKE")
|
||||
|
||||
# create own playlist
|
||||
playlistId = yt_brand.create_playlist(
|
||||
|
|
|
|||
|
|
@ -37,8 +37,6 @@ def parse_watch_track(data):
|
|||
if "likeEndpoint" in service:
|
||||
like_status = parse_like_status(service)
|
||||
|
||||
song_info = parse_song_runs(data["longBylineText"]["runs"])
|
||||
|
||||
track = {
|
||||
"videoId": data["videoId"],
|
||||
"title": nav(data, TITLE_TEXT),
|
||||
|
|
@ -49,7 +47,10 @@ def parse_watch_track(data):
|
|||
"inLibrary": library_status,
|
||||
"videoType": nav(data, ["navigationEndpoint", *NAVIGATION_VIDEO_TYPE], True),
|
||||
}
|
||||
track.update(song_info)
|
||||
if longBylineText := nav(data, ["longBylineText"]):
|
||||
song_info = parse_song_runs(longBylineText["runs"])
|
||||
track.update(song_info)
|
||||
|
||||
return track
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue