Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_charts is having KeyError #436

Closed
ankydv opened this issue Sep 23, 2023 · 6 comments · Fixed by #438
Closed

get_charts is having KeyError #436

ankydv opened this issue Sep 23, 2023 · 6 comments · Fixed by #438
Labels
bug Something isn't working

Comments

@ankydv
Copy link

ankydv commented Sep 23, 2023

[1.2.1/1.1.1] get_charts is having KeyError: -

To Reproduce
Steps to reproduce the behavior:

  1. Comment this section in explore.py since it's having KeyError, I'm unable to figure out.. Hence to avoid this error:-
charts['countries']['options'] = list(
             filter(None, [
                 nav(m, ['payload', 'musicFormBooleanChoice', 'opaqueToken'], True)
                 for m in nav(response, FRAMEWORK_MUTATIONS)
             ]))
  1. Call the get_charts function (auth or without auth).

Additional context
With some analysis I've figured out that youtube returns different response for different videos.
It appears to only occurs in 'videos' section. Not 'trending'.

**Cause
The NAVIGATION_VIDEO_ID in navigation.py is not sufficient to cover all types of responses from Youtube as the reponse of Youtube is inconsistent.

Expected structure of response:-

'navigationEndpoint':  {
					"clickTrackingParams": "CL0JEKCzAhgAIhMImaOrk6rAgQMVq8JzAR3dbAig",
					"watchEndpoint": {
						"videoId": "RLzC55ai0eo",
						"playlistId": "PL4fGSI1pDJn40WjZ6utkIuj2rNg-7iGsq",
						"loggingContext": {
							"vssLoggingContext": {
								"serializedContextData": "GiJQTDRmR1NJMXBESm40MFdqWjZ1dGtJdWoyck5nLTdpR3Nx"
							}
						},
						"watchEndpointMusicSupportedConfigs": {
							"watchEndpointMusicConfig": {
								"musicVideoType": "MUSIC_VIDEO_TYPE_OMV"
							}
						}
					}

In some cases, the response is like: -

'navigationEndpoint': {
					"clickTrackingParams": "CLEJEKCzAhgBIhMImaOrk6rAgQMVq8JzAR3dbAig",
					"browseEndpoint": {
						"browseId": "MPEDVAdGW7QDJiU",
						"params": "ggMnmgEkCiJQTDRmR1NJMXBESm40MFdqWjZ1dGtJdWoyck5nLTdpR3Nx",
						"browseEndpointContextSupportedConfigs": {
							"browseEndpointContextMusicConfig": {
								"pageType": "MUSIC_PAGE_TYPE_NON_MUSIC_AUDIO_TRACK_PAGE"
							}
						}
					}
				}


				}

Possible solution

In those cases, the video ID exists somewhere else, not in 'navigationEndpoint', the navigation should be like: -
NAVIGATION_VIDEO_ID_2 = ['menu','menuRenderer','items',0,'menuServiceItemRenderer','serviceEndpoint','queueAddEndpoint','queueTarget','videoId']

Hence we could fix it by excepting the KeyError with this nav instead.

Error.txt

@sigma67
Copy link
Owner

sigma67 commented Sep 23, 2023

Which region are you looking at? Please specify the failing call in more detail. If it's the default region for you please figure out which one that is.

@ankydv
Copy link
Author

ankydv commented Sep 23, 2023

I checked for default region as well as my region ('IN"). In both the cases there was the same issue. You could look the 'Error.txt' file that I have already dropped.

@Arnavop
Copy link

Arnavop commented Sep 24, 2023

I am also facing the same issue,
for "ZZ" region as well as for "IN" region its giving keyError.

@ankydv
Copy link
Author

ankydv commented Sep 25, 2023

I've the solution, I could raise a pull request.

@Arnavop
Copy link

Arnavop commented Sep 25, 2023

I've the solution, I could raise a pull request.

Yes please PR it
also whats the solution to this?

@sigma67 sigma67 added the bug Something isn't working label Sep 25, 2023
@ankydv
Copy link
Author

ankydv commented Sep 25, 2023

I've the solution, I could raise a pull request.

Yes please PR it also whats the solution to this?

I've Created a PR. You could view it.

@sigma67 sigma67 linked a pull request Sep 25, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants