From 2b6ced5226a718dff3ba43a59110fcd80ed17803 Mon Sep 17 00:00:00 2001 From: Lucas Macedo Date: Tue, 22 Mar 2022 22:56:21 -0300 Subject: [PATCH] get videoType from video results --- ytmusicapi/parsers/__init__.py | 3 +++ ytmusicapi/parsers/browsing.py | 1 + 2 files changed, 4 insertions(+) diff --git a/ytmusicapi/parsers/__init__.py b/ytmusicapi/parsers/__init__.py index 390b1bb..f89fe32 100644 --- a/ytmusicapi/parsers/__init__.py +++ b/ytmusicapi/parsers/__init__.py @@ -24,6 +24,9 @@ PAGE_TYPE = [ NAVIGATION_VIDEO_ID = ['navigationEndpoint', 'watchEndpoint', 'videoId'] NAVIGATION_PLAYLIST_ID = ['navigationEndpoint', 'watchEndpoint', 'playlistId'] NAVIGATION_WATCH_PLAYLIST_ID = ['navigationEndpoint', 'watchPlaylistEndpoint', 'playlistId'] +NAVIGATION_VIDEO_TYPE = [ + 'playNavigationEndpoint', 'watchEndpoint', 'watchEndpointMusicSupportedConfigs', 'watchEndpointMusicConfig', 'musicVideoType' +] HEADER_DETAIL = ['header', 'musicDetailHeaderRenderer'] DESCRIPTION = ['description'] + RUN_TEXT CAROUSEL = ['musicCarouselShelfRenderer'] diff --git a/ytmusicapi/parsers/browsing.py b/ytmusicapi/parsers/browsing.py index e8b88cd..5fed26a 100644 --- a/ytmusicapi/parsers/browsing.py +++ b/ytmusicapi/parsers/browsing.py @@ -107,6 +107,7 @@ class Parser: elif resultType == 'video': search_result['views'] = None + search_result['videoType'] = nav(data, PLAY_BUTTON + NAVIGATION_VIDEO_TYPE, True) elif resultType == 'upload': browse_id = nav(data, NAVIGATION_BROWSE_ID, True)