user234683 / youtube-local

browser-based client for watching Youtube anonymously and with greater page performance
GNU Affero General Public License v3.0
486 stars 62 forks source link

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

Closed dsg-sudo closed 4 months ago

dsg-sudo commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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

milind-j-gh commented 4 months ago

@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 commented 4 months ago

@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 commented 4 months ago

@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