diff --git a/tests/test.py b/tests/test.py index 96adff6..3eca60c 100644 --- a/tests/test.py +++ b/tests/test.py @@ -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") diff --git a/ytmusicapi/parsers/browsing.py b/ytmusicapi/parsers/browsing.py index 2fc745c..585d5c0 100644 --- a/ytmusicapi/parsers/browsing.py +++ b/ytmusicapi/parsers/browsing.py @@ -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