Fix uploads search (server-side changes)

This commit is contained in:
sigma67 2020-10-28 14:12:29 +01:00
commit bf32ba7221
No known key found for this signature in database
GPG key ID: 1545A01D4474BAF0
2 changed files with 9 additions and 11 deletions

View file

@ -41,7 +41,7 @@ class TestYTMusic(unittest.TestCase):
def test_search_uploads(self):
results = youtube_auth.search('audiomachine', 'uploads')
self.assertGreater(len(results), 0)
self.assertGreater(len(results), 10)
def test_get_artist(self):
results = youtube.get_artist("UCmMUZbaYdNH0bEd1PAlAqsA")

View file

@ -63,23 +63,21 @@ class Parser:
browse_id = nav(data, NAVIGATION_BROWSE_ID, True)
if not browse_id: # song result
flex_items = [
nav(get_flex_column_item(data, i), ['text', 'runs', 0], True) for i in range(3)
nav(get_flex_column_item(data, i), ['text', 'runs'], True) for i in range(2)
]
if flex_items[0]:
search_result['videoId'] = nav(flex_items[0], NAVIGATION_VIDEO_ID)
search_result['playlistId'] = nav(flex_items[0], NAVIGATION_PLAYLIST_ID)
search_result['videoId'] = nav(flex_items[0][0], NAVIGATION_VIDEO_ID)
search_result['playlistId'] = nav(flex_items[0][0], NAVIGATION_PLAYLIST_ID)
if flex_items[1]:
search_result['artist'] = {
'name': flex_items[1]['text'],
'id': nav(flex_items[1], NAVIGATION_BROWSE_ID)
'name': flex_items[1][0]['text'],
'id': nav(flex_items[1][0], NAVIGATION_BROWSE_ID)
}
if flex_items[2]:
search_result['album'] = {
'name': flex_items[2]['text'],
'id': nav(flex_items[2], NAVIGATION_BROWSE_ID)
'name': flex_items[1][2]['text'],
'id': nav(flex_items[1][2], NAVIGATION_BROWSE_ID)
}
search_result['duration'] = data['fixedColumns'][0][
'musicResponsiveListItemFixedColumnRenderer']['text']['runs'][0]['text']
search_result['duration'] = flex_items[1][4]['text']
search_result['resultType'] = 'song'
else: # artist or album result