From 917019745723d6ffacc32d7eb8c2676e5debba0c Mon Sep 17 00:00:00 2001 From: sigma67 Date: Thu, 18 Jan 2024 21:53:23 +0100 Subject: [PATCH] ruff: ruff specific rules --- pyproject.toml | 1 + tests/auth/test_browser.py | 2 +- tests/mixins/test_explore.py | 2 +- ytmusicapi/mixins/browsing.py | 20 +++++++------- ytmusicapi/mixins/explore.py | 6 ++--- ytmusicapi/mixins/library.py | 6 ++--- ytmusicapi/mixins/playlists.py | 4 +-- ytmusicapi/mixins/search.py | 2 +- ytmusicapi/mixins/watch.py | 4 +-- ytmusicapi/navigation.py | 48 ++++++++++++++++----------------- ytmusicapi/parsers/albums.py | 4 +-- ytmusicapi/parsers/browsing.py | 4 +-- ytmusicapi/parsers/explore.py | 2 +- ytmusicapi/parsers/playlists.py | 2 +- ytmusicapi/parsers/search.py | 8 +++--- ytmusicapi/parsers/songs.py | 4 +-- ytmusicapi/parsers/uploads.py | 2 +- ytmusicapi/parsers/watch.py | 2 +- 18 files changed, 62 insertions(+), 61 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1892a192..7706eab8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,6 +57,7 @@ ignore = [ "F403", "F405", "F821", "E731" ] extend-select = [ "I", # isort "UP", # pyupgrade + "RUF", # ruff ] [tool.mypy] diff --git a/tests/auth/test_browser.py b/tests/auth/test_browser.py index c77c8715..2eefb51d 100644 --- a/tests/auth/test_browser.py +++ b/tests/auth/test_browser.py @@ -11,7 +11,7 @@ def test_setup_browser(self, config, browser_filepath: str): headers_raw = config["auth"]["headers_raw"].split("\n") with ( mock.patch("sys.argv", ["ytmusicapi", "browser", "--file", browser_filepath]), - mock.patch("builtins.input", side_effect=(headers_raw + [EOFError()])), + mock.patch("builtins.input", side_effect=([*headers_raw, EOFError()])), ): headers = main() assert len(headers) >= 2 diff --git a/tests/mixins/test_explore.py b/tests/mixins/test_explore.py index 1a7e8f57..54f27fd6 100644 --- a/tests/mixins/test_explore.py +++ b/tests/mixins/test_explore.py @@ -2,7 +2,7 @@ class TestExplore: def test_get_mood_playlists(self, yt): categories = yt.get_mood_categories() assert len(list(categories)) > 0 - cat = list(categories)[0] + cat = next(iter(categories)) assert len(categories[cat]) > 0 playlists = yt.get_mood_playlists(categories[cat][0]["params"]) assert len(playlists) > 0 diff --git a/ytmusicapi/mixins/browsing.py b/ytmusicapi/mixins/browsing.py index 151d95d8..ca4c9b9c 100644 --- a/ytmusicapi/mixins/browsing.py +++ b/ytmusicapi/mixins/browsing.py @@ -110,7 +110,7 @@ def get_home(self, limit=3) -> List[Dict]: home = [] home.extend(parse_mixed_content(results)) - section_list = nav(response, SINGLE_COLUMN_TAB + ["sectionListRenderer"]) + section_list = nav(response, [*SINGLE_COLUMN_TAB, "sectionListRenderer"]) if "continuations" in section_list: request_func = lambda additionalParams: self._send_request(endpoint, body, additionalParams) @@ -237,10 +237,10 @@ def get_artist(self, channelId: str) -> Dict: subscription_button = header["subscriptionButton"]["subscribeButtonRenderer"] artist["channelId"] = subscription_button["channelId"] artist["shuffleId"] = nav( - header, ["playButton", "buttonRenderer"] + NAVIGATION_WATCH_PLAYLIST_ID, True + header, ["playButton", "buttonRenderer", *NAVIGATION_WATCH_PLAYLIST_ID], True ) artist["radioId"] = nav( - header, ["startRadioButton", "buttonRenderer"] + NAVIGATION_WATCH_PLAYLIST_ID, True + header, ["startRadioButton", "buttonRenderer", *NAVIGATION_WATCH_PLAYLIST_ID], True ) artist["subscribers"] = nav(subscription_button, ["subscriberCountText", "runs", 0, "text"], True) artist["subscribed"] = subscription_button["subscribed"] @@ -296,8 +296,8 @@ def get_artist_albums( ( nav( option, - MULTI_SELECT - + [ + [ + *MULTI_SELECT, "selectedCommand", "commandExecutorCommand", "commands", @@ -346,7 +346,7 @@ def get_user(self, channelId: str) -> Dict: Example:: { - "name": "4Tune – No Copyright Music", + "name": "4Tune - No Copyright Music", "videos": { "browseId": "UC44hbeRoCZVVMVg5z0FfIww", "results": [ @@ -387,7 +387,7 @@ def get_user(self, channelId: str) -> Dict: endpoint = "browse" body = {"browseId": channelId} response = self._send_request(endpoint, body) - user = {"name": nav(response, ["header", "musicVisualHeaderRenderer"] + TITLE_TEXT)} + user = {"name": nav(response, ["header", "musicVisualHeaderRenderer", *TITLE_TEXT])} results = nav(response, SINGLE_COLUMN_TAB + SECTION_LIST) user.update(self.parser.parse_artist_contents(results)) return user @@ -769,7 +769,7 @@ def get_song_related(self, browseId: str): raise Exception("Invalid browseId provided.") response = self._send_request("browse", {"browseId": browseId}) - sections = nav(response, ["contents"] + SECTION_LIST) + sections = nav(response, ["contents", *SECTION_LIST]) return parse_mixed_content(sections) def get_lyrics(self, browseId: str) -> Dict: @@ -793,10 +793,10 @@ def get_lyrics(self, browseId: str) -> Dict: response = self._send_request("browse", {"browseId": browseId}) lyrics["lyrics"] = nav( - response, ["contents"] + SECTION_LIST_ITEM + DESCRIPTION_SHELF + DESCRIPTION, True + response, ["contents", *SECTION_LIST_ITEM, *DESCRIPTION_SHELF, *DESCRIPTION], True ) lyrics["source"] = nav( - response, ["contents"] + SECTION_LIST_ITEM + DESCRIPTION_SHELF + ["footer"] + RUN_TEXT, True + response, ["contents", *SECTION_LIST_ITEM, *DESCRIPTION_SHELF, "footer", *RUN_TEXT], True ) return lyrics diff --git a/ytmusicapi/mixins/explore.py b/ytmusicapi/mixins/explore.py index 6cfa7e6e..93b3bb0a 100644 --- a/ytmusicapi/mixins/explore.py +++ b/ytmusicapi/mixins/explore.py @@ -53,7 +53,7 @@ def get_mood_categories(self) -> Dict: sections: Dict[str, Any] = {} response = self._send_request("browse", {"browseId": "FEmusic_moods_and_genres"}) for section in nav(response, SINGLE_COLUMN_TAB + SECTION_LIST): - title = nav(section, GRID + ["header", "gridHeaderRenderer"] + TITLE_TEXT) + title = nav(section, [*GRID, "header", "gridHeaderRenderer", *TITLE_TEXT]) sections[title] = [] for category in nav(section, GRID_ITEMS): sections[title].append( @@ -197,8 +197,8 @@ def get_charts(self, country: str = "ZZ") -> Dict: charts: Dict[str, Any] = {"countries": {}} menu = nav( results[0], - MUSIC_SHELF - + [ + [ + *MUSIC_SHELF, "subheaders", 0, "musicSideAlignedItemRenderer", diff --git a/ytmusicapi/mixins/library.py b/ytmusicapi/mixins/library.py index d66f6997..5f6e9fca 100644 --- a/ytmusicapi/mixins/library.py +++ b/ytmusicapi/mixins/library.py @@ -212,11 +212,11 @@ def get_history(self) -> List[Dict]: results = nav(response, SINGLE_COLUMN_TAB + SECTION_LIST) songs = [] for content in results: - data = nav(content, MUSIC_SHELF + ["contents"], True) + data = nav(content, [*MUSIC_SHELF, "contents"], True) if not data: - error = nav(content, ["musicNotifierShelfRenderer"] + TITLE, True) + error = nav(content, ["musicNotifierShelfRenderer", *TITLE], True) raise Exception(error) - menu_entries = [[-1] + MENU_SERVICE + FEEDBACK_TOKEN] + menu_entries = [[-1, *MENU_SERVICE, *FEEDBACK_TOKEN]] songlist = parse_playlist_items(data, menu_entries) for song in songlist: song["played"] = nav(content["musicShelfRenderer"], TITLE_TEXT) diff --git a/ytmusicapi/mixins/playlists.py b/ytmusicapi/mixins/playlists.py index c0a7b596..3f6ffe07 100644 --- a/ytmusicapi/mixins/playlists.py +++ b/ytmusicapi/mixins/playlists.py @@ -124,7 +124,7 @@ def get_playlist( if run_count > 1: playlist["author"] = { "name": nav(header, SUBTITLE2), - "id": nav(header, SUBTITLE_RUNS + [2] + NAVIGATION_BROWSE_ID, True), + "id": nav(header, [*SUBTITLE_RUNS, 2, *NAVIGATION_BROWSE_ID], True), } if run_count == 5: playlist["year"] = nav(header, SUBTITLE3) @@ -149,7 +149,7 @@ def get_playlist( request_func = lambda additionalParams: self._send_request(endpoint, body, additionalParams) # suggestions and related are missing e.g. on liked songs - section_list = nav(response, SINGLE_COLUMN_TAB + ["sectionListRenderer"]) + section_list = nav(response, [*SINGLE_COLUMN_TAB, "sectionListRenderer"]) playlist["related"] = [] if "continuations" in section_list: additionalParams = get_continuation_params(section_list) diff --git a/ytmusicapi/mixins/search.py b/ytmusicapi/mixins/search.py index ac9699c6..cc017127 100644 --- a/ytmusicapi/mixins/search.py +++ b/ytmusicapi/mixins/search.py @@ -214,7 +214,7 @@ def search( category = None # category "more from youtube" is missing sometimes if "messageRenderer" in results[0]: - category = nav(results.pop(0), ["messageRenderer"] + TEXT_RUN_TEXT) + category = nav(results.pop(0), ["messageRenderer", *TEXT_RUN_TEXT]) type = None else: continue diff --git a/ytmusicapi/mixins/watch.py b/ytmusicapi/mixins/watch.py index f5839eba..920625c2 100644 --- a/ytmusicapi/mixins/watch.py +++ b/ytmusicapi/mixins/watch.py @@ -147,13 +147,13 @@ def get_watch_playlist( related_browse_id = get_tab_browse_id(watchNextRenderer, 2) results = nav( - watchNextRenderer, TAB_CONTENT + ["musicQueueRenderer", "content", "playlistPanelRenderer"] + watchNextRenderer, [*TAB_CONTENT, "musicQueueRenderer", "content", "playlistPanelRenderer"] ) playlist = next( filter( bool, map( - lambda x: nav(x, ["playlistPanelVideoRenderer"] + NAVIGATION_PLAYLIST_ID, True), + lambda x: nav(x, ["playlistPanelVideoRenderer", *NAVIGATION_PLAYLIST_ID], True), results["contents"], ), ), diff --git a/ytmusicapi/navigation.py b/ytmusicapi/navigation.py index 955d2ee7..c3f49659 100644 --- a/ytmusicapi/navigation.py +++ b/ytmusicapi/navigation.py @@ -8,23 +8,23 @@ SINGLE_COLUMN = ["contents", "singleColumnBrowseResultsRenderer"] SINGLE_COLUMN_TAB = SINGLE_COLUMN + TAB_CONTENT SECTION = ["sectionListRenderer"] -SECTION_LIST = SECTION + ["contents"] +SECTION_LIST = [*SECTION, "contents"] SECTION_LIST_ITEM = SECTION + CONTENT -ITEM_SECTION = ["itemSectionRenderer"] + CONTENT +ITEM_SECTION = ["itemSectionRenderer", *CONTENT] MUSIC_SHELF = ["musicShelfRenderer"] GRID = ["gridRenderer"] -GRID_ITEMS = GRID + ["items"] +GRID_ITEMS = [*GRID, "items"] MENU = ["menu", "menuRenderer"] -MENU_ITEMS = MENU + ["items"] -MENU_LIKE_STATUS = MENU + ["topLevelButtons", 0, "likeButtonRenderer", "likeStatus"] +MENU_ITEMS = [*MENU, "items"] +MENU_LIKE_STATUS = [*MENU, "topLevelButtons", 0, "likeButtonRenderer", "likeStatus"] MENU_SERVICE = ["menuServiceItemRenderer", "serviceEndpoint"] TOGGLE_MENU = "toggleMenuServiceItemRenderer" PLAY_BUTTON = ["overlay", "musicItemThumbnailOverlayRenderer", "content", "musicPlayButtonRenderer"] NAVIGATION_BROWSE = ["navigationEndpoint", "browseEndpoint"] -NAVIGATION_BROWSE_ID = NAVIGATION_BROWSE + ["browseId"] +NAVIGATION_BROWSE_ID = [*NAVIGATION_BROWSE, "browseId"] PAGE_TYPE = ["browseEndpointContextSupportedConfigs", "browseEndpointContextMusicConfig", "pageType"] WATCH_VIDEO_ID = ["watchEndpoint", "videoId"] -NAVIGATION_VIDEO_ID = ["navigationEndpoint"] + WATCH_VIDEO_ID +NAVIGATION_VIDEO_ID = ["navigationEndpoint", *WATCH_VIDEO_ID] QUEUE_VIDEO_ID = ["queueAddEndpoint", "queueTarget", "videoId"] NAVIGATION_PLAYLIST_ID = ["navigationEndpoint", "watchEndpoint", "playlistId"] NAVIGATION_WATCH_PLAYLIST_ID = ["navigationEndpoint", "watchPlaylistEndpoint", "playlistId"] @@ -35,40 +35,40 @@ "musicVideoType", ] TITLE = ["title", "runs", 0] -TITLE_TEXT = ["title"] + RUN_TEXT +TITLE_TEXT = ["title", *RUN_TEXT] TEXT_RUNS = ["text", "runs"] -TEXT_RUN = TEXT_RUNS + [0] -TEXT_RUN_TEXT = TEXT_RUN + ["text"] -SUBTITLE = ["subtitle"] + RUN_TEXT +TEXT_RUN = [*TEXT_RUNS, 0] +TEXT_RUN_TEXT = [*TEXT_RUN, "text"] +SUBTITLE = ["subtitle", *RUN_TEXT] SUBTITLE_RUNS = ["subtitle", "runs"] -SUBTITLE2 = SUBTITLE_RUNS + [2, "text"] -SUBTITLE3 = SUBTITLE_RUNS + [4, "text"] +SUBTITLE2 = [*SUBTITLE_RUNS, 2, "text"] +SUBTITLE3 = [*SUBTITLE_RUNS, 4, "text"] THUMBNAIL = ["thumbnail", "thumbnails"] -THUMBNAILS = ["thumbnail", "musicThumbnailRenderer"] + THUMBNAIL -THUMBNAIL_RENDERER = ["thumbnailRenderer", "musicThumbnailRenderer"] + THUMBNAIL -THUMBNAIL_CROPPED = ["thumbnail", "croppedSquareThumbnailRenderer"] + THUMBNAIL +THUMBNAILS = ["thumbnail", "musicThumbnailRenderer", *THUMBNAIL] +THUMBNAIL_RENDERER = ["thumbnailRenderer", "musicThumbnailRenderer", *THUMBNAIL] +THUMBNAIL_CROPPED = ["thumbnail", "croppedSquareThumbnailRenderer", *THUMBNAIL] FEEDBACK_TOKEN = ["feedbackEndpoint", "feedbackToken"] BADGE_PATH = [0, "musicInlineBadgeRenderer", "accessibilityData", "accessibilityData", "label"] -BADGE_LABEL = ["badges"] + BADGE_PATH -SUBTITLE_BADGE_LABEL = ["subtitleBadges"] + BADGE_PATH -CATEGORY_TITLE = ["musicNavigationButtonRenderer", "buttonText"] + RUN_TEXT +BADGE_LABEL = ["badges", *BADGE_PATH] +SUBTITLE_BADGE_LABEL = ["subtitleBadges", *BADGE_PATH] +CATEGORY_TITLE = ["musicNavigationButtonRenderer", "buttonText", *RUN_TEXT] CATEGORY_PARAMS = ["musicNavigationButtonRenderer", "clickCommand", "browseEndpoint", "params"] MRLIR = "musicResponsiveListItemRenderer" MTRIR = "musicTwoRowItemRenderer" TASTE_PROFILE_ITEMS = ["contents", "tastebuilderRenderer", "contents"] TASTE_PROFILE_ARTIST = ["title", "runs"] SECTION_LIST_CONTINUATION = ["continuationContents", "sectionListContinuation"] -MENU_PLAYLIST_ID = MENU_ITEMS + [0, "menuNavigationItemRenderer"] + NAVIGATION_WATCH_PLAYLIST_ID +MENU_PLAYLIST_ID = [*MENU_ITEMS, 0, "menuNavigationItemRenderer", *NAVIGATION_WATCH_PLAYLIST_ID] MULTI_SELECT = ["musicMultiSelectMenuItemRenderer"] HEADER_DETAIL = ["header", "musicDetailHeaderRenderer"] HEADER_SIDE = ["header", "musicSideAlignedItemRenderer"] DESCRIPTION_SHELF = ["musicDescriptionShelfRenderer"] -DESCRIPTION = ["description"] + RUN_TEXT +DESCRIPTION = ["description", *RUN_TEXT] CAROUSEL = ["musicCarouselShelfRenderer"] IMMERSIVE_CAROUSEL = ["musicImmersiveCarouselShelfRenderer"] -CAROUSEL_CONTENTS = CAROUSEL + ["contents"] -CAROUSEL_TITLE = ["header", "musicCarouselShelfBasicHeaderRenderer"] + TITLE -CARD_SHELF_TITLE = ["header", "musicCardShelfHeaderBasicRenderer"] + TITLE_TEXT +CAROUSEL_CONTENTS = [*CAROUSEL, "contents"] +CAROUSEL_TITLE = ["header", "musicCarouselShelfBasicHeaderRenderer", *TITLE] +CARD_SHELF_TITLE = ["header", "musicCardShelfHeaderBasicRenderer", *TITLE_TEXT] FRAMEWORK_MUTATIONS = ["frameworkUpdates", "entityBatchUpdate", "mutations"] diff --git a/ytmusicapi/parsers/albums.py b/ytmusicapi/parsers/albums.py index 2d7e6852..5861144d 100644 --- a/ytmusicapi/parsers/albums.py +++ b/ytmusicapi/parsers/albums.py @@ -26,9 +26,9 @@ def parse_album_header(response): # add to library/uploaded menu = nav(header, MENU) toplevel = menu["topLevelButtons"] - album["audioPlaylistId"] = nav(toplevel, [0, "buttonRenderer"] + NAVIGATION_WATCH_PLAYLIST_ID, True) + album["audioPlaylistId"] = nav(toplevel, [0, "buttonRenderer", *NAVIGATION_WATCH_PLAYLIST_ID], True) if not album["audioPlaylistId"]: - album["audioPlaylistId"] = nav(toplevel, [0, "buttonRenderer"] + NAVIGATION_PLAYLIST_ID, True) + album["audioPlaylistId"] = nav(toplevel, [0, "buttonRenderer", *NAVIGATION_PLAYLIST_ID], True) service = nav(toplevel, [1, "buttonRenderer", "defaultServiceEndpoint"], True) if service: album["likeStatus"] = parse_like_status(service) diff --git a/ytmusicapi/parsers/browsing.py b/ytmusicapi/parsers/browsing.py index 4b2a493e..eaf518d6 100644 --- a/ytmusicapi/parsers/browsing.py +++ b/ytmusicapi/parsers/browsing.py @@ -7,13 +7,13 @@ def parse_mixed_content(rows): for row in rows: if DESCRIPTION_SHELF[0] in row: results = nav(row, DESCRIPTION_SHELF) - title = nav(results, ["header"] + RUN_TEXT) + title = nav(results, ["header", *RUN_TEXT]) contents = nav(results, DESCRIPTION) else: results = next(iter(row.values())) if "contents" not in results: continue - title = nav(results, CAROUSEL_TITLE + ["text"]) + title = nav(results, [*CAROUSEL_TITLE, "text"]) contents = [] for result in results["contents"]: data = nav(result, [MTRIR], True) diff --git a/ytmusicapi/parsers/explore.py b/ytmusicapi/parsers/explore.py index 510b5a7a..5893d600 100644 --- a/ytmusicapi/parsers/explore.py +++ b/ytmusicapi/parsers/explore.py @@ -42,7 +42,7 @@ def parse_chart_trending(data): def parse_ranking(data): return { - "rank": nav(data, ["customIndexColumn", "musicCustomIndexColumnRenderer"] + TEXT_RUN_TEXT), + "rank": nav(data, ["customIndexColumn", "musicCustomIndexColumnRenderer", *TEXT_RUN_TEXT]), "trend": TRENDS[ nav(data, ["customIndexColumn", "musicCustomIndexColumnRenderer", "icon", "iconType"]) ], diff --git a/ytmusicapi/parsers/playlists.py b/ytmusicapi/parsers/playlists.py index c7b42bc3..b005caf8 100644 --- a/ytmusicapi/parsers/playlists.py +++ b/ytmusicapi/parsers/playlists.py @@ -75,7 +75,7 @@ def parse_playlist_items(results, menu_entries: Optional[List[List]] = None, is_ videoType = nav( data, - MENU_ITEMS + [0, "menuNavigationItemRenderer", "navigationEndpoint"] + NAVIGATION_VIDEO_TYPE, + [*MENU_ITEMS, 0, "menuNavigationItemRenderer", "navigationEndpoint", *NAVIGATION_VIDEO_TYPE], True, ) diff --git a/ytmusicapi/parsers/search.py b/ytmusicapi/parsers/search.py index e64e9b53..d831be7d 100644 --- a/ytmusicapi/parsers/search.py +++ b/ytmusicapi/parsers/search.py @@ -34,8 +34,8 @@ def parse_top_result(data, search_result_types): search_result["videoType"] = nav(on_tap, NAVIGATION_VIDEO_TYPE) if result_type in ["song", "video", "album"]: - search_result["videoId"] = nav(data, ["onTap"] + WATCH_VIDEO_ID, True) - search_result["videoType"] = nav(data, ["onTap"] + NAVIGATION_VIDEO_TYPE, True) + search_result["videoId"] = nav(data, ["onTap", *WATCH_VIDEO_ID], True) + search_result["videoType"] = nav(data, ["onTap", *NAVIGATION_VIDEO_TYPE], True) search_result["title"] = nav(data, TITLE_TEXT) runs = nav(data, ["subtitle", "runs"]) @@ -52,7 +52,7 @@ def parse_top_result(data, search_result_types): def parse_search_result(data, search_result_types, result_type, category): default_offset = (not result_type or result_type == "album") * 2 search_result = {"category": category} - video_type = nav(data, PLAY_BUTTON + ["playNavigationEndpoint"] + NAVIGATION_VIDEO_TYPE, True) + video_type = nav(data, [*PLAY_BUTTON, "playNavigationEndpoint", *NAVIGATION_VIDEO_TYPE], True) if not result_type and video_type: result_type = "song" if video_type == "MUSIC_VIDEO_TYPE_ATV" else "video" @@ -120,7 +120,7 @@ def parse_search_result(data, search_result_types, result_type, category): if result_type in ["song", "video"]: search_result["videoId"] = nav( - data, PLAY_BUTTON + ["playNavigationEndpoint", "watchEndpoint", "videoId"], True + data, [*PLAY_BUTTON, "playNavigationEndpoint", "watchEndpoint", "videoId"], True ) search_result["videoType"] = video_type diff --git a/ytmusicapi/parsers/songs.py b/ytmusicapi/parsers/songs.py index 9347b51a..8f93ada0 100644 --- a/ytmusicapi/parsers/songs.py +++ b/ytmusicapi/parsers/songs.py @@ -66,8 +66,8 @@ def parse_song_library_status(item) -> bool: def parse_song_menu_tokens(item): toggle_menu = item[TOGGLE_MENU] - library_add_token = nav(toggle_menu, ["defaultServiceEndpoint"] + FEEDBACK_TOKEN, True) - library_remove_token = nav(toggle_menu, ["toggledServiceEndpoint"] + FEEDBACK_TOKEN, True) + library_add_token = nav(toggle_menu, ["defaultServiceEndpoint", *FEEDBACK_TOKEN], True) + library_remove_token = nav(toggle_menu, ["toggledServiceEndpoint", *FEEDBACK_TOKEN], True) in_library = parse_song_library_status(item) if in_library: diff --git a/ytmusicapi/parsers/uploads.py b/ytmusicapi/parsers/uploads.py index 91023d7b..98087a2b 100644 --- a/ytmusicapi/parsers/uploads.py +++ b/ytmusicapi/parsers/uploads.py @@ -14,7 +14,7 @@ def parse_uploaded_items(results): "musicDeletePrivatelyOwnedEntityCommand" ]["entityId"] - videoId = nav(data, MENU_ITEMS + [0] + MENU_SERVICE)["queueAddEndpoint"]["queueTarget"]["videoId"] + videoId = nav(data, [*MENU_ITEMS, 0, *MENU_SERVICE])["queueAddEndpoint"]["queueTarget"]["videoId"] title = get_item_text(data, 0) like = nav(data, MENU_LIKE_STATUS) diff --git a/ytmusicapi/parsers/watch.py b/ytmusicapi/parsers/watch.py index eac07779..6822cb75 100644 --- a/ytmusicapi/parsers/watch.py +++ b/ytmusicapi/parsers/watch.py @@ -47,7 +47,7 @@ def parse_watch_track(data): "feedbackTokens": feedback_tokens, "likeStatus": like_status, "inLibrary": library_status, - "videoType": nav(data, ["navigationEndpoint"] + NAVIGATION_VIDEO_TYPE, True), + "videoType": nav(data, ["navigationEndpoint", *NAVIGATION_VIDEO_TYPE], True), } track.update(song_info) return track