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

500 Uncaught exception Error...Again:( #201

Closed
dsg-sudo opened this issue Mar 8, 2024 · 8 comments
Closed

500 Uncaught exception Error...Again:( #201

dsg-sudo opened this issue Mar 8, 2024 · 8 comments

Comments

@dsg-sudo
Copy link

dsg-sudo commented Mar 8, 2024

I get this error pretty much in each click.

Screenshot 2024-03-08 at 16-55-43 Error

Screenshot 2024-03-07 at 18-48-41 Error

@MBCX
Copy link

MBCX commented Mar 9, 2024

Me too indeed, worth to note that this only happens when trying to watch a video. Browsing works just fine

Traceback (most recent call last):
  File "E:\Repos\youtube-local\env\lib\site-packages\flask\app.py", line 2525, in wsgi_app
    response = self.full_dispatch_request()
  File "E:\Repos\youtube-local\env\lib\site-packages\flask\app.py", line 1822, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "E:\Repos\youtube-local\env\lib\site-packages\flask\app.py", line 1820, in full_dispatch_request
    rv = self.dispatch_request()
  File "E:\Repos\youtube-local\env\lib\site-packages\flask\app.py", line 1796, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "E:\Repos\youtube-local\youtube\watch.py", line 604, in get_watch_page
    util.check_gevent_exceptions(tasks[1])
  File "E:\Repos\youtube-local\youtube\util.py", line 602, in check_gevent_exceptions
    raise task.exception
  File "src\\gevent\\greenlet.py", line 908, in gevent._gevent_cgreenlet.Greenlet.run
  File "E:\Repos\youtube-local\youtube\watch.py", line 381, in extract_info
    util.check_gevent_exceptions(*tasks)
  File "E:\Repos\youtube-local\youtube\util.py", line 602, in check_gevent_exceptions
    raise task.exception
  File "src\\gevent\\greenlet.py", line 908, in gevent._gevent_cgreenlet.Greenlet.run
  File "E:\Repos\youtube-local\youtube\watch.py", line 338, in fetch_player_response
    return util.call_youtube_api(client, 'player', {
  File "E:\Repos\youtube-local\youtube\util.py", line 728, in call_youtube_api
    response = fetch_url(
  File "E:\Repos\youtube-local\youtube\util.py", line 359, in fetch_url
    raise FetchError(str(response.status), reason=response.reason,
youtube.util.FetchError: HTTP error during request: 400 Bad Request

@metrast
Copy link

metrast commented Mar 9, 2024

the same happens for me:

  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Applications/youtube-local-2.8.6/youtube/watch.py", line 605, in get_watch_page
    util.check_gevent_exceptions(tasks[1])
  File "/Applications/youtube-local-2.8.6/youtube/util.py", line 602, in check_gevent_exceptions
    raise task.exception
  File "src/gevent/greenlet.py", line 906, in gevent._gevent_cgreenlet.Greenlet.run
  File "/Applications/youtube-local-2.8.6/youtube/watch.py", line 382, in extract_info
    util.check_gevent_exceptions(*tasks)
  File "/Applications/youtube-local-2.8.6/youtube/util.py", line 602, in check_gevent_exceptions
    raise task.exception
  File "src/gevent/greenlet.py", line 906, in gevent._gevent_cgreenlet.Greenlet.run
  File "/Applications/youtube-local-2.8.6/youtube/watch.py", line 338, in fetch_player_response
    return util.call_youtube_api(client, 'player', {
  File "/Applications/youtube-local-2.8.6/youtube/util.py", line 728, in call_youtube_api
    response = fetch_url(
  File "/Applications/youtube-local-2.8.6/youtube/util.py", line 359, in fetch_url
    raise FetchError(str(response.status), reason=response.reason,
youtube.util.FetchError: HTTP error during request: 400 Bad Request

@MBCX
Copy link

MBCX commented Mar 9, 2024

Found a temporary (maybe) solution.

What's causing the error is that by default, the app is trying to use the "android" api configuration from the innertube configurations. And from the looks of it, appears to not work anymore. The "web" one though still works. Locate watch.py and change this from "android" to "web" and should work now.

    # gevent.spawn(fetch_player_response, 'android', video_id) <---- Change this
    gevent.spawn(fetch_player_response, 'web', video_id)

Though after some quick test, the video performance is worse.

@MBCX
Copy link

MBCX commented Mar 9, 2024

Nevermind, found a better solution.

It appears that the android innertube configuration from this repo is out of date compared to yt-dlp. I changed it to this (combined some from this repo and theirs):

    'android': {
        'INNERTUBE_API_KEY': 'AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w',
        'INNERTUBE_CONTEXT': {
            'client': {
                'hl': 'en',
                'gl': 'US',
                'clientName': 'ANDROID',
                'clientVersion': '18.11.34',
                'androidSdkVersion': 30,
                'osName': 'Android',
                'osVersion': '12',
                'userAgent': 'com.google.android.youtube/18.11.34 (Linux; U; Android 12) gzip'
            }
        },
        'INNERTUBE_CONTEXT_CLIENT_NAME': 3,
        'REQUIRE_JS_PLAYER': False
    },

And it works fine, and video performance is good.

@Vjay15
Copy link

Vjay15 commented Mar 9, 2024

thanks @MBCX that fixed it, you are a hero =)

@milind-j-gh
Copy link

@MBCX can you tell exactly in which file and where i have to paste this code for it to work. I'm a noob please help

@Vjay15
Copy link

Vjay15 commented Mar 11, 2024

@MBCX can you tell exactly in which file and where i have to paste this code for it to work. I'm a noob please help

Go to the youtube-local directory and then look for youtube folder in there you should find util.py, the code where the change is needed is in there :)

@user234683
Copy link
Owner

@MBCX can you tell exactly in which file and where i have to paste this code for it to work. I'm a noob please help

It is fixed in the latest release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants