Add likeStatus for uploaded songs
This commit is contained in:
parent
38d0b6ea90
commit
2fa0603694
3 changed files with 12 additions and 17 deletions
|
|
@ -9,3 +9,5 @@ own = owned_playlist_id
|
||||||
|
|
||||||
[uploads]
|
[uploads]
|
||||||
file = song_in_tests_directory.mp3
|
file = song_in_tests_directory.mp3
|
||||||
|
private_album_id = sample_id_of_private_album
|
||||||
|
private_artist_id = sample_id_of_private_artist
|
||||||
|
|
@ -183,20 +183,12 @@ class TestYTMusic(unittest.TestCase):
|
||||||
self.assertEqual(response, 'STATUS_SUCCEEDED')
|
self.assertEqual(response, 'STATUS_SUCCEEDED')
|
||||||
|
|
||||||
def test_get_library_upload_album(self):
|
def test_get_library_upload_album(self):
|
||||||
songs = youtube_auth.get_library_upload_songs()
|
album = youtube_auth.get_library_upload_album(config['uploads']['private_album_id'])
|
||||||
for song in songs:
|
self.assertGreater(len(album['tracks']), 0)
|
||||||
if song['album']:
|
|
||||||
album = youtube_auth.get_library_upload_album(song['album']['id'])
|
|
||||||
self.assertGreater(len(album['tracks']), 0)
|
|
||||||
break
|
|
||||||
|
|
||||||
def test_get_library_upload_artist(self):
|
def test_get_library_upload_artist(self):
|
||||||
songs = youtube_auth.get_library_upload_songs()
|
tracks = youtube_auth.get_library_upload_artist(config['uploads']['private_artist_id'])
|
||||||
for song in songs:
|
self.assertGreater(len(tracks), 0)
|
||||||
if song['artist']:
|
|
||||||
tracks = youtube_auth.get_library_upload_artist(song['artist'][0]['id'])
|
|
||||||
self.assertGreater(len(tracks), 0)
|
|
||||||
break
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ ITEM_SECTION = ['itemSectionRenderer', 'contents', 0]
|
||||||
MUSIC_SHELF = [0, 'musicShelfRenderer']
|
MUSIC_SHELF = [0, 'musicShelfRenderer']
|
||||||
CONTINUATION = ['continuations', 0, 'nextContinuationData', 'continuation']
|
CONTINUATION = ['continuations', 0, 'nextContinuationData', 'continuation']
|
||||||
MENU_ITEMS = ['menu', 'menuRenderer', 'items']
|
MENU_ITEMS = ['menu', 'menuRenderer', 'items']
|
||||||
|
MENU_LIKE_STATUS = ['menu', 'menuRenderer', 'topLevelButtons', 0, 'likeButtonRenderer', 'likeStatus']
|
||||||
MENU_SERVICE = ['menuServiceItemRenderer', 'serviceEndpoint']
|
MENU_SERVICE = ['menuServiceItemRenderer', 'serviceEndpoint']
|
||||||
PLAY_BUTTON = [
|
PLAY_BUTTON = [
|
||||||
'overlay', 'musicItemThumbnailOverlayRenderer', 'content', 'musicPlayButtonRenderer'
|
'overlay', 'musicItemThumbnailOverlayRenderer', 'content', 'musicPlayButtonRenderer'
|
||||||
|
|
@ -135,8 +136,7 @@ def parse_playlist_items(results):
|
||||||
|
|
||||||
like = None
|
like = None
|
||||||
if 'menu' in data:
|
if 'menu' in data:
|
||||||
like = data['menu']['menuRenderer']['topLevelButtons'][0]['likeButtonRenderer'][
|
like = nav(data, MENU_LIKE_STATUS)
|
||||||
'likeStatus']
|
|
||||||
|
|
||||||
song = {
|
song = {
|
||||||
'videoId': videoId,
|
'videoId': videoId,
|
||||||
|
|
@ -172,13 +172,14 @@ def parse_uploaded_items(results):
|
||||||
+ MENU_SERVICE)['queueAddEndpoint']['queueTarget']['videoId']
|
+ MENU_SERVICE)['queueAddEndpoint']['queueTarget']['videoId']
|
||||||
|
|
||||||
title = get_item_text(data, 0)
|
title = get_item_text(data, 0)
|
||||||
|
like = nav(data, MENU_LIKE_STATUS)
|
||||||
song = {
|
song = {
|
||||||
'entityId': entityId,
|
'entityId': entityId,
|
||||||
'videoId': videoId,
|
'videoId': videoId,
|
||||||
'title': title,
|
'title': title,
|
||||||
'artist': None,
|
'artist': None,
|
||||||
'album': None
|
'album': None,
|
||||||
|
'likeStatus': like
|
||||||
}
|
}
|
||||||
if get_flex_column_item(data, 1):
|
if get_flex_column_item(data, 1):
|
||||||
song['artist'] = parse_song_artists(data, 1)
|
song['artist'] = parse_song_artists(data, 1)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue