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

update_format_with_type_info fails for specific video #130

Closed zrose584 closed 7 months ago

zrose584 commented 2 years ago

When loading https://www.youtube.com/watch?v=0NZxNAZdHQo I get

[...]
  File "/youtube-local/youtube/watch.py", line 357, in extract_info
    info = yt_data_extract.extract_watch_info_from_html(watch_page)
  File "/youtube-local/youtube/yt_data_extract/watch_extraction.py", line 737, in extract_watch_info_from_html
    return extract_watch_info(fake_polymer_json)
  File "/youtube-local/youtube/yt_data_extract/watch_extraction.py", line 588, in extract_watch_info
    _extract_formats(info, player_response)
  File "/youtube-local/youtube/yt_data_extract/watch_extraction.py", line 433, in _extract_formats
    update_format_with_type_info(fmt, yt_fmt)
  File "/youtube-local/youtube/yt_data_extract/watch_extraction.py", line 392, in update_format_with_type_info
    type, fmt['ext'], codecs = match.groups()
AttributeError: 'NoneType' object has no attribute 'groups'

Any ideas?

user234683 commented 2 years ago

A regular expression is failing to match, so the match object is None. Two ways I would debug this: Insert a print statement to print the string that is supposed to be matched. Also examine the JSON given by YouTube using the method mentioned in #128 to see what about it is malformed (can compare to the JSON for a video where this problem isn't happening). Probably just bad coding on my part. It shouldn't fail if a regex doesn't match, since YouTube can give random results sometimes

Message ID: @.***>

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

user234683 commented 7 months ago

Fixed in https://github.com/user234683/youtube-local/commit/0e383cd5ed9fa05ea06aecfc8e969ade919f9365 See #159