Return empty list if 'musicShelfRenderer' not in list of uploaded artists (#71)

This commit is contained in:
apastel 2020-09-06 09:41:31 -07:00
commit d9c88009d8
No known key found for this signature in database
GPG key ID: F59A233F18242C34
2 changed files with 10 additions and 1 deletions

View file

@ -230,6 +230,11 @@ class TestYTMusic(unittest.TestCase):
results = youtube_auth.get_library_upload_artists(50)
self.assertGreater(len(results), 25)
@unittest.skip("Must not have any uploaded artsts to pass")
def test_get_library_upload_artists_empty(self):
results = youtube_auth.get_library_upload_artists(100)
self.assertEquals(len(results), 0)
def test_upload_song(self):
self.assertRaises(Exception, youtube_auth.upload_song, 'song.wav')
response = youtube_auth.upload_song(config['uploads']['file'])

View file

@ -95,7 +95,11 @@ class UploadsMixin:
response = self._send_request(endpoint, body)
results = find_object_by_key(nav(response, SINGLE_COLUMN_TAB + SECTION_LIST),
'itemSectionRenderer')
results = nav(results, ITEM_SECTION)['musicShelfRenderer']
results = nav(results, ITEM_SECTION)
if 'musicShelfRenderer' not in results:
return []
else:
results = results['musicShelfRenderer']
artists = parse_artists(results['contents'], True)
if 'continuations' in results: