Add get_album, get_artist (#4)
This commit is contained in:
parent
6cdfb39055
commit
872547e368
3 changed files with 218 additions and 36 deletions
|
|
@ -1,6 +1,20 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
# Static helper methods
|
#commonly used navigation paths
|
||||||
|
SINGLE_COLUMN_TAB = ['contents', 'singleColumnBrowseResultsRenderer', 'tabs', 0, 'tabRenderer', 'content']
|
||||||
|
SECTION_LIST = ['sectionListRenderer', 'contents']
|
||||||
|
ITEM_SECTION = ['itemSectionRenderer', 'contents', 0]
|
||||||
|
CONTINUATION = ['continuations', 0, 'nextContinuationData', 'continuation']
|
||||||
|
MENU_ITEMS = ['menu', 'menuRenderer', 'items']
|
||||||
|
MENU_SERVICE = ['menuServiceItemRenderer', 'serviceEndpoint']
|
||||||
|
PLAY_BUTTON = ['overlay', 'musicItemThumbnailOverlayRenderer', 'content', 'musicPlayButtonRenderer']
|
||||||
|
CAROUSEL_TITLE = ['header', 'musicCarouselShelfBasicHeaderRenderer', 'title', 'runs', 0]
|
||||||
|
FRAMEWORK_MUTATIONS = ['frameworkUpdates', 'entityBatchUpdate', 'mutations']
|
||||||
|
|
||||||
|
def nav(root, items):
|
||||||
|
"""Access a nested object in root by item sequence."""
|
||||||
|
for k in items: root = root[k]
|
||||||
|
return root
|
||||||
|
|
||||||
|
|
||||||
def parse_playlist_items(results, owned=False):
|
def parse_playlist_items(results, owned=False):
|
||||||
|
|
@ -16,23 +30,33 @@ def parse_playlist_items(results, owned=False):
|
||||||
# if playlist is not owned, the playlist item can't be interacted with
|
# if playlist is not owned, the playlist item can't be interacted with
|
||||||
videoId = setVideoId = None
|
videoId = setVideoId = None
|
||||||
if owned:
|
if owned:
|
||||||
for item in data['menu']['menuRenderer']['items']:
|
for item in nav(data, MENU_ITEMS):
|
||||||
if 'menuServiceItemRenderer' in item and 'playlistEditEndpoint' in item['menuServiceItemRenderer']['serviceEndpoint']:
|
if 'menuServiceItemRenderer' in item and 'playlistEditEndpoint' in nav(item, MENU_SERVICE):
|
||||||
setVideoId = item['menuServiceItemRenderer']['serviceEndpoint']['playlistEditEndpoint']['actions'][0]['setVideoId']
|
setVideoId = nav(item, MENU_SERVICE)['playlistEditEndpoint']['actions'][0]['setVideoId']
|
||||||
videoId = item['menuServiceItemRenderer']['serviceEndpoint']['playlistEditEndpoint']['actions'][0]['removedVideoId']
|
videoId = nav(item, MENU_SERVICE)['playlistEditEndpoint']['actions'][0]['removedVideoId']
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
# if item is not playable, there is no videoId
|
# if item is not playable, there is no videoId
|
||||||
if 'playNavigationEndpoint' in data['overlay']['musicItemThumbnailOverlayRenderer']['content']['musicPlayButtonRenderer']:
|
if 'playNavigationEndpoint' in nav(data, PLAY_BUTTON):
|
||||||
videoId = data['overlay']['musicItemThumbnailOverlayRenderer']['content']['musicPlayButtonRenderer']['playNavigationEndpoint']['watchEndpoint']['videoId']
|
videoId = nav(data, PLAY_BUTTON)['playNavigationEndpoint']['watchEndpoint']['videoId']
|
||||||
|
|
||||||
runs = [None] * 3
|
runs = [None] * 3
|
||||||
for i in range(len(runs)):
|
for i in range(len(runs)):
|
||||||
if 'runs' in data['flexColumns'][i]['musicResponsiveListItemFlexColumnRenderer']['text']:
|
if 'text' in data['flexColumns'][i]['musicResponsiveListItemFlexColumnRenderer']:
|
||||||
runs[i] = data['flexColumns'][i]['musicResponsiveListItemFlexColumnRenderer']['text']['runs'][0]['text']
|
runs[i] = get_item_text(data, i)
|
||||||
|
|
||||||
|
duration = None
|
||||||
|
if 'fixedColumns' in data:
|
||||||
|
duration = data['fixedColumns'][0]['musicResponsiveListItemFixedColumnRenderer']['text']['simpleText']
|
||||||
|
|
||||||
|
song = {'videoId': videoId, 'title': runs[0], 'artist': runs[1], 'album': runs[2]}
|
||||||
|
if duration:
|
||||||
|
song['duration'] = duration
|
||||||
|
if owned:
|
||||||
|
song['setVideoId'] = setVideoId
|
||||||
|
|
||||||
song = {'videoId': videoId, 'title': runs[0], 'artist': runs[1], 'album': runs[2], 'setVideoId': setVideoId}
|
|
||||||
songs.append(song)
|
songs.append(song)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Item " + str(count) + ": " + str(e))
|
print("Item " + str(count) + ": " + str(e))
|
||||||
|
|
||||||
|
|
@ -42,12 +66,11 @@ def parse_uploaded_items(results):
|
||||||
songs = []
|
songs = []
|
||||||
for result in results:
|
for result in results:
|
||||||
data = result['musicResponsiveListItemRenderer']
|
data = result['musicResponsiveListItemRenderer']
|
||||||
entityId = data['menu']['menuRenderer']['items'][-1]['menuNavigationItemRenderer']['navigationEndpoint'][
|
entityId = nav(data, MENU_ITEMS)[-1]['menuNavigationItemRenderer']['navigationEndpoint'][
|
||||||
'confirmDialogEndpoint']['content']['confirmDialogRenderer']['confirmButton']['buttonRenderer']['command'][
|
'confirmDialogEndpoint']['content']['confirmDialogRenderer']['confirmButton']['buttonRenderer']['command'][
|
||||||
'musicDeletePrivatelyOwnedEntityCommand']['entityId']
|
'musicDeletePrivatelyOwnedEntityCommand']['entityId']
|
||||||
|
|
||||||
videoId = data['menu']['menuRenderer']['items'][0]['menuServiceItemRenderer']['serviceEndpoint'][
|
videoId = nav(data, MENU_ITEMS + [0] + MENU_SERVICE)['queueAddEndpoint']['queueTarget']['videoId']
|
||||||
'queueAddEndpoint']['queueTarget']['videoId']
|
|
||||||
|
|
||||||
title = get_item_text(data, 0)
|
title = get_item_text(data, 0)
|
||||||
artist = get_item_text(data, 1)
|
artist = get_item_text(data, 1)
|
||||||
|
|
@ -69,8 +92,7 @@ def parse_search_result(data, resultType = None):
|
||||||
resultType = 'album'
|
resultType = 'album'
|
||||||
|
|
||||||
if resultType in ['song', 'video']:
|
if resultType in ['song', 'video']:
|
||||||
search_result['videoId'] = data['overlay']['musicItemThumbnailOverlayRenderer']['content'][
|
search_result['videoId'] = nav(data, PLAY_BUTTON)['playNavigationEndpoint']['watchEndpoint']['videoId']
|
||||||
'musicPlayButtonRenderer']['playNavigationEndpoint']['watchEndpoint']['videoId']
|
|
||||||
search_result['title'] = get_item_text(data, 0)
|
search_result['title'] = get_item_text(data, 0)
|
||||||
search_result['artist'] = get_item_text(data, 1 + default)
|
search_result['artist'] = get_item_text(data, 1 + default)
|
||||||
|
|
||||||
|
|
@ -107,12 +129,24 @@ def parse_search_result(data, resultType = None):
|
||||||
|
|
||||||
|
|
||||||
def get_item_text(item, index):
|
def get_item_text(item, index):
|
||||||
if not 'runs' in item['flexColumns'][index]['musicResponsiveListItemFlexColumnRenderer']['text']:
|
if 'runs' not in item['flexColumns'][index]['musicResponsiveListItemFlexColumnRenderer']['text']:
|
||||||
return ''
|
return None
|
||||||
|
|
||||||
return item['flexColumns'][index]['musicResponsiveListItemFlexColumnRenderer']['text']['runs'][0]['text']
|
return item['flexColumns'][index]['musicResponsiveListItemFlexColumnRenderer']['text']['runs'][0]['text']
|
||||||
|
|
||||||
|
|
||||||
|
def prepare_browse_endpoint(type, browseId):
|
||||||
|
return {
|
||||||
|
'browseEndpointContextSupportedConfigs':
|
||||||
|
{
|
||||||
|
"browseEndpointContextMusicConfig":
|
||||||
|
{
|
||||||
|
"pageType": "MUSIC_PAGE_TYPE_" + type
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'browseId': browseId
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def html_to_txt(html_text):
|
def html_to_txt(html_text):
|
||||||
tags = re.findall("<[^>]+>",html_text)
|
tags = re.findall("<[^>]+>",html_text)
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,15 @@ class TestYTMusic(unittest.TestCase):
|
||||||
results = youtube_auth.search("Oasis Wonderwall")
|
results = youtube_auth.search("Oasis Wonderwall")
|
||||||
self.assertGreater(len(results), 0)
|
self.assertGreater(len(results), 0)
|
||||||
|
|
||||||
|
def test_get_artist(self):
|
||||||
|
results = youtube.get_artist("UCmMUZbaYdNH0bEd1PAlAqsA")
|
||||||
|
self.assertEqual(len(results), 4)
|
||||||
|
|
||||||
|
def test_get_album(self):
|
||||||
|
results = youtube.get_album("MPREb_BQZvl3BFGay")
|
||||||
|
self.assertEqual(len(results), 4)
|
||||||
|
self.assertEqual(len(results['tracks']), 7)
|
||||||
|
|
||||||
def test_get_uploaded_songs(self):
|
def test_get_uploaded_songs(self):
|
||||||
results = youtube_auth.get_uploaded_songs(50)
|
results = youtube_auth.get_uploaded_songs(50)
|
||||||
self.assertEqual(len(results), 50)
|
self.assertEqual(len(results), 50)
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,7 @@ import json
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
import ntpath
|
import ntpath
|
||||||
import os
|
import os
|
||||||
from ytmusicapi.helpers import \
|
from ytmusicapi.helpers import *
|
||||||
parse_playlist_items, parse_uploaded_items, parse_search_result, html_to_txt
|
|
||||||
from ytmusicapi.setup import setup
|
from ytmusicapi.setup import setup
|
||||||
|
|
||||||
params = '?alt=json&key=AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30'
|
params = '?alt=json&key=AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30'
|
||||||
|
|
@ -140,7 +139,7 @@ class YTMusic:
|
||||||
else:
|
else:
|
||||||
results = response['contents']
|
results = response['contents']
|
||||||
|
|
||||||
results = results['sectionListRenderer']['contents']
|
results = nav(results, SECTION_LIST)
|
||||||
|
|
||||||
# no results
|
# no results
|
||||||
if len(results) == 1 and 'itemSectionRenderer' in results:
|
if len(results) == 1 and 'itemSectionRenderer' in results:
|
||||||
|
|
@ -161,6 +160,154 @@ class YTMusic:
|
||||||
|
|
||||||
return search_results
|
return search_results
|
||||||
|
|
||||||
|
def get_artist(self, channelId):
|
||||||
|
"""
|
||||||
|
Get data about an artist
|
||||||
|
|
||||||
|
:param channelId: channel id of the artist
|
||||||
|
:return: Detailed information about the artist and
|
||||||
|
their songs, albums, singles and videos. Example:
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "Oasis"
|
||||||
|
"description": "Oasis were ...",
|
||||||
|
"views": "1,838,795,605",
|
||||||
|
"songs": {
|
||||||
|
"browseId": "VLPLMpM3Z0118S42R1npOhcjoakLIv1aqnS1",
|
||||||
|
"results": [
|
||||||
|
{
|
||||||
|
"videoId": "ZrOKjDZOtkA",
|
||||||
|
"title": "Wonderwall (Remastered)",
|
||||||
|
"artist": "Oasis",
|
||||||
|
"album": "(What's The Story) Morning Glory? (Remastered)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"albums": {
|
||||||
|
"results": [
|
||||||
|
{
|
||||||
|
"title": "Familiar To Millions",
|
||||||
|
"year": "2018",
|
||||||
|
"browseId": "MPREb_AYetWMZunqA"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"browseId": "UCmMUZbaYdNH0bEd1PAlAqsA"
|
||||||
|
},
|
||||||
|
"singles": {
|
||||||
|
"results": [
|
||||||
|
{
|
||||||
|
"title": "Stand By Me (Mustique Demo)",
|
||||||
|
"year": "2016",
|
||||||
|
"browseId": "MPREb_7MPKLhibN5G"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"browseId": "UCmMUZbaYdNH0bEd1PAlAqsA"
|
||||||
|
},
|
||||||
|
"videos": {
|
||||||
|
"results": [
|
||||||
|
{
|
||||||
|
"title": "Wonderwall",
|
||||||
|
"views": "358M",
|
||||||
|
"videoId": "bx1Bh8ZvH84",
|
||||||
|
"playlistId": "PLMpM3Z0118S5xuNckw1HUcj1D021AnMEB"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"browseId": "VLPLMpM3Z0118S5xuNckw1HUcj1D021AnMEB"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"""
|
||||||
|
body = prepare_browse_endpoint("ARTIST", channelId)
|
||||||
|
endpoint = 'browse'
|
||||||
|
response = self.__send_request(endpoint, body)
|
||||||
|
results = nav(response, SINGLE_COLUMN_TAB + SECTION_LIST)
|
||||||
|
|
||||||
|
artist = {}
|
||||||
|
artist['name'] = response['header']['musicImmersiveHeaderRenderer']['title']['runs'][0]['text']
|
||||||
|
artist['description'] = results[-1]['musicDescriptionShelfRenderer']['description']['runs'][0]['text']
|
||||||
|
artist['views'] = results[-1]['musicDescriptionShelfRenderer']['subheader']['runs'][0]['text'].split(' ')[0]
|
||||||
|
artist['songs'] = {}
|
||||||
|
artist['songs']['browseId'] = results[0]['musicShelfRenderer']['title']['runs'][0]['navigationEndpoint']['browseEndpoint']['browseId']
|
||||||
|
artist['songs']['results'] = parse_playlist_items(results[0]['musicShelfRenderer']['contents'])
|
||||||
|
|
||||||
|
categories = ['albums', 'singles', 'videos']
|
||||||
|
for category in categories:
|
||||||
|
data = [r['musicCarouselShelfRenderer'] for r in results if 'musicCarouselShelfRenderer' in r
|
||||||
|
and nav(r['musicCarouselShelfRenderer'], CAROUSEL_TITLE)['text'].lower() == category]
|
||||||
|
if len(data) > 0:
|
||||||
|
artist[category] = {"results": []}
|
||||||
|
if 'navigationEndpoint' in nav(data[0], CAROUSEL_TITLE):
|
||||||
|
artist[category]['browseId'] = nav(data[0], CAROUSEL_TITLE)['navigationEndpoint']['browseEndpoint']['browseId']
|
||||||
|
if category in ['albums', 'singles']:
|
||||||
|
artist[category]['params'] = nav(data[0], CAROUSEL_TITLE)['navigationEndpoint']['browseEndpoint']['params']
|
||||||
|
|
||||||
|
for item in data[0]['contents']:
|
||||||
|
result = {'title': item['musicTwoRowItemRenderer']['title']['runs'][0]['text']}
|
||||||
|
if category == 'albums':
|
||||||
|
result['year'] = item['musicTwoRowItemRenderer']['subtitle']['runs'][2]['text']
|
||||||
|
result['browseId'] = item['musicTwoRowItemRenderer']['title']['runs'][0]['navigationEndpoint']['browseEndpoint']['browseId']
|
||||||
|
elif category == 'singles':
|
||||||
|
result['year'] = item['musicTwoRowItemRenderer']['subtitle']['runs'][0]['text']
|
||||||
|
result['browseId'] = item['musicTwoRowItemRenderer']['title']['runs'][0]['navigationEndpoint']['browseEndpoint']['browseId']
|
||||||
|
elif category == 'videos':
|
||||||
|
result['views'] = item['musicTwoRowItemRenderer']['subtitle']['runs'][2]['text'].split(' ')[0]
|
||||||
|
result['videoId'] = item['musicTwoRowItemRenderer']['title']['runs'][0]['navigationEndpoint']['watchEndpoint']['videoId']
|
||||||
|
result['playlistId'] = item['musicTwoRowItemRenderer']['title']['runs'][0]['navigationEndpoint']['watchEndpoint']['playlistId']
|
||||||
|
artist[category]['results'].append(result)
|
||||||
|
|
||||||
|
return artist
|
||||||
|
|
||||||
|
def get_artist_songs(self, playlistId):
|
||||||
|
body = {"browseId": playlistId}
|
||||||
|
endpoint = 'browse'
|
||||||
|
response = self.__send_request(endpoint, body)
|
||||||
|
pass
|
||||||
|
|
||||||
|
def get_artist_albums(self, channelId, params):
|
||||||
|
body = {"browseId": channelId, "params": params}
|
||||||
|
endpoint = 'browse'
|
||||||
|
response = self.__send_request(endpoint, body)
|
||||||
|
pass
|
||||||
|
|
||||||
|
def get_album(self, browseId):
|
||||||
|
"""
|
||||||
|
Get information and tracks of an album
|
||||||
|
|
||||||
|
:param browseId: browseId of the album, for example
|
||||||
|
returned by :py:func:`search`
|
||||||
|
:return: Dictionary with title, description, artist and tracks
|
||||||
|
|
||||||
|
Each track is in the following format:
|
||||||
|
|
||||||
|
{
|
||||||
|
"index": "1",
|
||||||
|
"title": "WIEE (feat. Mesto)",
|
||||||
|
"artists": "Martin Garrix",
|
||||||
|
"videoId": "8xMNeXI9wxI",
|
||||||
|
"lengthMs": "203406"
|
||||||
|
}
|
||||||
|
|
||||||
|
"""
|
||||||
|
body = prepare_browse_endpoint("ALBUM", browseId)
|
||||||
|
endpoint = 'browse'
|
||||||
|
response = self.__send_request(endpoint, body)
|
||||||
|
album = {}
|
||||||
|
album['title'] = nav(response, FRAMEWORK_MUTATIONS)[0]['payload']['musicAlbumRelease']['title']
|
||||||
|
album['description'] = nav(response, FRAMEWORK_MUTATIONS)[1]['payload']['musicAlbumReleaseDetail']['description']
|
||||||
|
album['artist'] = nav(response, FRAMEWORK_MUTATIONS)[3]['payload']['musicArtist']['name']
|
||||||
|
album['tracks'] = []
|
||||||
|
for item in nav(response, FRAMEWORK_MUTATIONS)[4:]:
|
||||||
|
if 'musicTrack' in item['payload']:
|
||||||
|
track = {}
|
||||||
|
track['index'] = item['payload']['musicTrack']['albumTrackIndex']
|
||||||
|
track['title'] = item['payload']['musicTrack']['title']
|
||||||
|
track['artists'] = item['payload']['musicTrack']['artistNames']
|
||||||
|
track['videoId'] = item['payload']['musicTrack']['videoId']
|
||||||
|
track['lengthMs'] = item['payload']['musicTrack']['lengthMs']
|
||||||
|
album['tracks'].append(track)
|
||||||
|
|
||||||
|
return album
|
||||||
|
|
||||||
def get_playlists(self):
|
def get_playlists(self):
|
||||||
"""
|
"""
|
||||||
Retrieves the content of the 'Library' page
|
Retrieves the content of the 'Library' page
|
||||||
|
|
@ -179,7 +326,8 @@ class YTMusic:
|
||||||
body = {'browseId': 'FEmusic_liked_playlists'}
|
body = {'browseId': 'FEmusic_liked_playlists'}
|
||||||
endpoint = 'browse'
|
endpoint = 'browse'
|
||||||
response = self.__send_request(endpoint, body)
|
response = self.__send_request(endpoint, body)
|
||||||
results = response['contents']['singleColumnBrowseResultsRenderer']['tabs'][0]['tabRenderer']['content']['sectionListRenderer']['contents'][1]['itemSectionRenderer']['contents'][0]['gridRenderer']['items']
|
|
||||||
|
results = nav(response, SINGLE_COLUMN_TAB + SECTION_LIST + [1] + ITEM_SECTION)['gridRenderer']['items']
|
||||||
playlists = []
|
playlists = []
|
||||||
# skip first item ("New Playlist" button)
|
# skip first item ("New Playlist" button)
|
||||||
for result in results[1:]:
|
for result in results[1:]:
|
||||||
|
|
@ -210,8 +358,7 @@ class YTMusic:
|
||||||
body = {'browseId': 'FEmusic_history'}
|
body = {'browseId': 'FEmusic_history'}
|
||||||
endpoint = 'browse'
|
endpoint = 'browse'
|
||||||
response = self.__send_request(endpoint, body)
|
response = self.__send_request(endpoint, body)
|
||||||
results = response['contents']['singleColumnBrowseResultsRenderer']['tabs'][0]['tabRenderer']['content'][
|
results = nav(response, SINGLE_COLUMN_TAB + SECTION_LIST)
|
||||||
'sectionListRenderer']['contents']
|
|
||||||
songs = []
|
songs = []
|
||||||
for content in results:
|
for content in results:
|
||||||
data = content['musicShelfRenderer']['contents']
|
data = content['musicShelfRenderer']['contents']
|
||||||
|
|
@ -267,18 +414,10 @@ class YTMusic:
|
||||||
needed for moving/removing playlist items
|
needed for moving/removing playlist items
|
||||||
|
|
||||||
"""
|
"""
|
||||||
body = { 'browseEndpointContextSupportedConfigs':
|
body = prepare_browse_endpoint("PLAYLIST", "VL" + playlistId)
|
||||||
{
|
|
||||||
"browseEndpointContextMusicConfig":
|
|
||||||
{
|
|
||||||
"pageType": "MUSIC_PAGE_TYPE_PLAYLIST"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'browseId': "VL" + playlistId
|
|
||||||
}
|
|
||||||
endpoint = 'browse'
|
endpoint = 'browse'
|
||||||
response = self.__send_request(endpoint, body)
|
response = self.__send_request(endpoint, body)
|
||||||
results = response['contents']['singleColumnBrowseResultsRenderer']['tabs'][0]['tabRenderer']['content']['sectionListRenderer']['contents'][0]['musicPlaylistShelfRenderer']
|
results = nav(response, SINGLE_COLUMN_TAB + SECTION_LIST)[0]['musicPlaylistShelfRenderer']
|
||||||
songs = []
|
songs = []
|
||||||
if 'musicDetailHeaderRenderer' in response['header']: #playlist not owned
|
if 'musicDetailHeaderRenderer' in response['header']: #playlist not owned
|
||||||
header = response['header']['musicDetailHeaderRenderer']
|
header = response['header']['musicDetailHeaderRenderer']
|
||||||
|
|
@ -294,7 +433,7 @@ class YTMusic:
|
||||||
request_count = 1
|
request_count = 1
|
||||||
|
|
||||||
while request_count * 100 < songs_to_get:
|
while request_count * 100 < songs_to_get:
|
||||||
ctoken = results['continuations'][0]['nextContinuationData']['continuation']
|
ctoken = nav(results, CONTINUATION)
|
||||||
additionalParams = "&ctoken=" + ctoken + "&continuation=" + ctoken
|
additionalParams = "&ctoken=" + ctoken + "&continuation=" + ctoken
|
||||||
|
|
||||||
response = self.__send_request(endpoint, body, additionalParams)
|
response = self.__send_request(endpoint, body, additionalParams)
|
||||||
|
|
@ -431,14 +570,14 @@ class YTMusic:
|
||||||
endpoint = 'browse'
|
endpoint = 'browse'
|
||||||
body = {"browseId": "FEmusic_library_privately_owned_tracks"}
|
body = {"browseId": "FEmusic_library_privately_owned_tracks"}
|
||||||
response = self.__send_request(endpoint, body)
|
response = self.__send_request(endpoint, body)
|
||||||
results = response['contents']['singleColumnBrowseResultsRenderer']['tabs'][0]['tabRenderer']['content']['sectionListRenderer']['contents'][1]['itemSectionRenderer']['contents'][0]['musicShelfRenderer']
|
results = nav(response, SINGLE_COLUMN_TAB + SECTION_LIST + [1] + ITEM_SECTION)['musicShelfRenderer']
|
||||||
songs = []
|
songs = []
|
||||||
|
|
||||||
songs.extend(parse_uploaded_items(results['contents'][1:]))
|
songs.extend(parse_uploaded_items(results['contents'][1:]))
|
||||||
|
|
||||||
request_count = 1
|
request_count = 1
|
||||||
while request_count * 25 < limit:
|
while request_count * 25 < limit:
|
||||||
ctoken = results['continuations'][0]['nextContinuationData']['continuation']
|
ctoken = nav(results, CONTINUATION)
|
||||||
additionalParams = "&ctoken=" + ctoken + "&continuation=" + ctoken
|
additionalParams = "&ctoken=" + ctoken + "&continuation=" + ctoken
|
||||||
response = self.__send_request(endpoint, body, additionalParams)
|
response = self.__send_request(endpoint, body, additionalParams)
|
||||||
results = response['continuationContents']['musicShelfContinuation']
|
results = response['continuationContents']['musicShelfContinuation']
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue