aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/watch.py
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2020-12-12 23:11:54 -0800
committerJames Taylor <user234683@users.noreply.github.com>2020-12-12 23:11:54 -0800
commit9d0be82e7425641a58a551fefce26385dee2f9d3 (patch)
treebecf2435ebed465914845747199925606cfd54ac /youtube/watch.py
parent6443cedf6299ba5a516df5a00cc78fb0b6800a1e (diff)
downloadyt-local-9d0be82e7425641a58a551fefce26385dee2f9d3.tar.lz
yt-local-9d0be82e7425641a58a551fefce26385dee2f9d3.tar.xz
yt-local-9d0be82e7425641a58a551fefce26385dee2f9d3.zip
Always extract from html watch page to get base.js url
Youtube removed the url from the pbj responses. They are now only in the html page. Replaces previous fix for the missing base.js issue.
Diffstat (limited to 'youtube/watch.py')
-rw-r--r--youtube/watch.py31
1 files changed, 6 insertions, 25 deletions
diff --git a/youtube/watch.py b/youtube/watch.py
index f7b8051..7f3b5be 100644
--- a/youtube/watch.py
+++ b/youtube/watch.py
@@ -189,20 +189,7 @@ def decrypt_signatures(info, video_id):
if not yt_data_extract.requires_decryption(info):
return False
if not info['player_name']:
- # base.js urls missing. Usually this is because there is no
- # embedded player response; instead it's in the json as playerResponse,
- # but there's no base.js key.
- # Example: https://www.youtube.com/watch?v=W6iQPK3F16U
- # See https://github.com/user234683/youtube-local/issues/22#issuecomment-706395160
- url = 'https://m.youtube.com/watch?v=' + video_id + '&bpctr=9999999999'
- html_watch_page = util.fetch_url(
- url,
- headers=watch_headers,
- report_text='Fetching html watch page to retrieve missing base.js',
- debug_name='watch_page_html').decode('utf-8')
- err = yt_data_extract.update_with_missing_base_js(info, html_watch_page)
- if err:
- return err
+ return 'Could not find player name'
player_name = info['player_name']
if player_name in decrypt_cache:
@@ -222,21 +209,15 @@ def decrypt_signatures(info, video_id):
def extract_info(video_id, use_invidious, playlist_id=None, index=None):
# bpctr=9999999999 will bypass are-you-sure dialogs for controversial
# videos
- url = 'https://m.youtube.com/watch?v=' + video_id + '&pbj=1&bpctr=9999999999'
+ url = 'https://m.youtube.com/watch?v=' + video_id + '&bpctr=9999999999'
if playlist_id:
url += '&list=' + playlist_id
if index:
url += '&index=' + index
- polymer_json = util.fetch_url(url, headers=watch_headers,
- debug_name='watch')
- polymer_json = polymer_json.decode('utf-8')
- # TODO: Decide whether this should be done in yt_data_extract.extract_watch_info
- try:
- polymer_json = json.loads(polymer_json)
- except json.decoder.JSONDecodeError:
- traceback.print_exc()
- return {'error': 'Failed to parse json response'}
- info = yt_data_extract.extract_watch_info(polymer_json)
+ watch_page = util.fetch_url(url, headers=watch_headers,
+ debug_name='watch')
+ watch_page = watch_page.decode('utf-8')
+ info = yt_data_extract.extract_watch_info_from_html(watch_page)
# request player urls if it's missing
# see https://github.com/user234683/youtube-local/issues/22#issuecomment-706395160