user234683 / youtube-local

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

Not Found Unknown channel tab when opening a YouTube channel #147

Closed ByJumperX4 closed 1 year ago

ByJumperX4 commented 2 years ago

Since yesterday, if you click on a YouTube channel itself (not a video), it throws an error like this one:

image

user234683 commented 2 years ago

Can't reproduce. For instance, this link https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw is working fine for me. Example link?

Message ID: @.***>

[ { @.": "http://schema.org", @.": "EmailMessage", "potentialAction": { @.": "ViewAction", "target": "https://github.com/user234683/youtube-local/issues/147", "url": "https://github.com/user234683/youtube-local/issues/147", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { @.": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

ByJumperX4 commented 2 years ago

The link you sent doesn't work for me, i'll try with a different browser

ByJumperX4 commented 2 years ago

Nope, I tried Ungoogled Chromium, Brave and Firefox, it does the same for all of them, I also tried git cloning the repo and launching it by hand (instead of using my systemd service from my AUR package), still the same, here are the logs but they seem pretty normal to me:

$ ~/src/youtube-local> python3 server.py                                                [0|9|19:49]
Running in non-portable mode
Tor routing is OFF - your Youtube activity is NOT anonymous
Started httpserver on port 8080
127.0.0.1 - - [2022-09-03 19:49:49] "GET /https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw HTTP/1.1" 404 256 0.001625
user234683 commented 2 years ago

At line 244, in the function def get_channel_page_general_url(base_url, tab, request, channel_id=None): in ./youtube/channel.py, insert the code:

    print(yt_app.url_map)
    print('base_url', base_url)
    print('tab', tab)

and post what it prints when you access the channel.

Also, what Python version? python3 --version And what versions of Flask and its dependencies? Can use pip3 list or can install pipdeptree via pip3 install pipdeptree and run pipdeptree -p Flask. These are the dependencies:

Flask==2.2.2
  - click [required: >=8.0, installed: 8.1.3]
    - importlib-metadata [required: Any, installed: 4.12.0]
      - typing-extensions [required: >=3.6.4, installed: 3.7.4.3]
      - zipp [required: >=0.5, installed: 3.4.0]
  - importlib-metadata [required: >=3.6.0, installed: 4.12.0]
    - typing-extensions [required: >=3.6.4, installed: 3.7.4.3]
    - zipp [required: >=0.5, installed: 3.4.0]
  - itsdangerous [required: >=2.0, installed: 2.1.2]
  - Jinja2 [required: >=3.0, installed: 3.1.2]
    - MarkupSafe [required: >=2.0, installed: 2.1.1]
  - Werkzeug [required: >=2.2.2, installed: 2.2.2]
    - MarkupSafe [required: >=2.1.1, installed: 2.1.1]
ByJumperX4 commented 2 years ago

I have python 3.10.6 from the Arch Linux repos, same for all the dependencies (they're not installed with pip)

Flask==2.1.3
  - click [required: >=8.0, installed: 8.1.3]
  - itsdangerous [required: >=2.0, installed: 2.1.2]
  - Jinja2 [required: >=3.0, installed: 3.1.2]
    - MarkupSafe [required: >=2.0, installed: 2.1.1]
  - Werkzeug [required: >=2.0, installed: 2.2.1]
    - MarkupSafe [required: >=2.1.1, installed: 2.1.1]

If you need the version of any other lib just check https://archlinux.org/packages/

Here are the logs:

Running in non-portable mode
Tor routing is OFF - your Youtube activity is NOT anonymous
Started httpserver on port 8080
Map([<Rule '/static/<filename>' (HEAD, GET, OPTIONS) -> static>,
 <Rule '/settings' (HEAD, POST, GET, OPTIONS) -> settings_page>,
 <Rule '/' (HEAD, GET, OPTIONS) -> homepage>,
 <Rule '/shared.css' (HEAD, GET, OPTIONS) -> get_css>,
 <Rule '/comments' (HEAD, GET, OPTIONS) -> get_comments_page>,
 <Rule '/playlists/<playlist_name>' (HEAD, GET, OPTIONS) -> get_local_playlist_page>,
 <Rule '/playlists' (HEAD, GET, OPTIONS) -> get_local_playlist_page>,
 <Rule '/playlists/<playlist_name>' (POST, OPTIONS) -> path_edit_playlist>,
 <Rule '/edit_playlist' (POST, OPTIONS) -> edit_playlist>,
 <Rule '/data/playlist_thumbnails/<playlist_name>/<thumbnail>' (HEAD, GET, OPTIONS) -> serve_thumbnail>,
 <Rule '/ytl-api/storyboard.vtt' (HEAD, GET, OPTIONS) -> get_storyboard_vtt>,
 <Rule '/shorts/<video_id>' (HEAD, GET, OPTIONS) -> get_watch_page>,
 <Rule '/embed/<video_id>' (HEAD, GET, OPTIONS) -> get_watch_page>,
 <Rule '/shorts' (HEAD, GET, OPTIONS) -> get_watch_page>,
 <Rule '/embed' (HEAD, GET, OPTIONS) -> get_watch_page>,
 <Rule '/watch' (HEAD, GET, OPTIONS) -> get_watch_page>,
 <Rule '/api/<dummy>' (HEAD, GET, OPTIONS) -> get_captions>,
 <Rule '/watch/transcript/<caption_path>' (HEAD, GET, OPTIONS) -> get_transcript>,
 <Rule '/search' (HEAD, GET, OPTIONS) -> get_search_page>,
 <Rule '/results' (HEAD, GET, OPTIONS) -> get_search_page>,
 <Rule '/opensearch.xml' (HEAD, GET, OPTIONS) -> get_search_engine_xml>,
 <Rule '/playlist' (HEAD, GET, OPTIONS) -> get_playlist_page>,
 <Rule '/import_subscriptions' (POST, OPTIONS) -> import_subscriptions>,
 <Rule '/export_subscriptions' (POST, OPTIONS) -> export_subscriptions>,
 <Rule '/subscription_manager' (HEAD, GET, OPTIONS) -> get_subscription_manager_page>,
 <Rule '/subscription_manager' (POST, OPTIONS) -> post_subscription_manager_page>,
 <Rule '/feed/subscriptions' (HEAD, GET, OPTIONS) -> get_subscriptions_page>,
 <Rule '/subscriptions' (HEAD, GET, OPTIONS) -> get_subscriptions_page>,
 <Rule '/feed/subscriptions' (POST, OPTIONS) -> post_subscriptions_page>,
 <Rule '/subscriptions' (POST, OPTIONS) -> post_subscriptions_page>,
 <Rule '/data/subscription_thumbnails/<thumbnail>' (HEAD, GET, OPTIONS) -> serve_subscription_thumbnail>,
 <Rule '/channel/<channel_id>/<tab>' (HEAD, GET, OPTIONS) -> get_channel_page>,
 <Rule '/channel/<channel_id>/' (HEAD, GET, OPTIONS) -> get_channel_page>,
 <Rule '/user/<username>/<tab>' (HEAD, GET, OPTIONS) -> get_user_page>,
 <Rule '/user/<username>/' (HEAD, GET, OPTIONS) -> get_user_page>,
 <Rule '/c/<custom>/<tab>' (HEAD, GET, OPTIONS) -> get_custom_c_page>,
 <Rule '/c/<custom>/' (HEAD, GET, OPTIONS) -> get_custom_c_page>,
 <Rule '/<custom>/<tab>' (HEAD, GET, OPTIONS) -> get_toplevel_custom_page>,
 <Rule '/<custom>' (HEAD, GET, OPTIONS) -> get_toplevel_custom_page>])
base_url https://www.youtube.com/channel
tab UCSuHzQ3GrHSzoBbwrIq3LLA
127.0.0.1 - - [2022-09-04 04:35:01] "GET /https://www.youtube.com/channel/UCSuHzQ3GrHSzoBbwrIq3LLA HTTP/1.1" 404 256 0.002236

PS: If I add /videos at the end of the URL it works just fine. I tested with http://127.0.0.1:8080/https://www.youtube.com/channel/UCSuHzQ3GrHSzoBbwrIq3LLA, I get the error. http://127.0.0.1:8080/https://www.youtube.com/channel/UCSuHzQ3GrHSzoBbwrIq3LLA/videos, it works

I think it just fails to default to the videos tab of the channel and then just picks nothing instead

user234683 commented 2 years ago

I'm 95% sure the problem is that Werkzeug (the library for matching paths) is falsely matching that url to the /<custom>/<tab> rule instead of to the /channel/<channel_id>/ rule as it should, so it's calling the wrong function. To confirm, could you insert this code on those lines as well and post the output:

    print('url_rule.endpoint', request.url_rule.endpoint)
    print(yt_app.view_functions)
    traceback.print_stack()

Is it possible to see what packages you updated on 9/1/22 that caused this issue to start (From which version to which)? I'm suspecting there is a bug in Werkzeug that started when Python was updated. Or it could be because Werkzeug is on a newer, but not the newest version, and they introduced a bug that they later fixed (I updated from a super old version to the newest version via pip and didn't see the issue on either version).

Also, does the problem happen if you have a trailing slash on the url like http://127.0.0.1:8080/https://www.youtube.com/channel/UCSuHzQ3GrHSzoBbwrIq3LLA/

ByJumperX4 commented 2 years ago

/var/log/pacman.log indeed tells me that werkzeug is one of the python libs that got updated the 31st August on my system:

[2022-08-31T20:06:25+0200] [ALPM] installed python-cssselect (1.1.0-9)
[2022-08-31T20:06:25+0200] [ALPM] upgraded python-numpy (1.23.1-1 -> 1.23.2-1)
[2022-08-31T20:06:28+0200] [ALPM] upgraded python-msgpack (1.0.3-1 -> 1.0.4-1)
[2022-08-31T20:06:28+0200] [ALPM] upgraded python-ordered-set (4.0.2-6 -> 4.1.0-1)
[2022-08-31T20:06:28+0200] [ALPM] upgraded python-pep517 (0.12.0-4 -> 0.13.0-1)
[2022-08-31T20:06:28+0200] [ALPM] upgraded python-pydantic (1.9.2-1 -> 1.10.0-1)
[2022-08-31T20:06:28+0200] [ALPM] upgraded python-setuptools (1:62.3.0-1 -> 1:62.3.1-1)
[2022-08-31T20:06:29+0200] [ALPM] upgraded python-werkzeug (2.1.2-1 -> 2.2.0-1)

But I can't really test the code you sent because for some reason it works now 🤔

ByJumperX4 commented 2 years ago

Oh werkzeug got updated to 2.2.2 in arch that's probably why