Work around video throttling using android user-agent
Temporary fix for #95 Signed-off-by: Jesús <heckyel@hyperbola.info>
This commit is contained in:
parent
ec5e995262
commit
2e5a1133e3
@ -354,13 +354,26 @@ def extract_info(video_id, use_invidious, playlist_id=None, index=None):
|
|||||||
watch_page = watch_page.decode('utf-8')
|
watch_page = watch_page.decode('utf-8')
|
||||||
info = yt_data_extract.extract_watch_info_from_html(watch_page)
|
info = yt_data_extract.extract_watch_info_from_html(watch_page)
|
||||||
|
|
||||||
# request player urls if it's missing
|
context = {
|
||||||
# see https://github.com/user234683/youtube-local/issues/22#issuecomment-706395160
|
'client': {
|
||||||
|
'clientName': 'ANDROID',
|
||||||
|
'clientVersion': '16.20',
|
||||||
|
'gl': 'US',
|
||||||
|
'hl': 'en',
|
||||||
|
},
|
||||||
|
# https://github.com/yt-dlp/yt-dlp/pull/575#issuecomment-887739287
|
||||||
|
'thirdParty': {
|
||||||
|
'embedUrl': 'https://google.com', # Can be any valid URL
|
||||||
|
}
|
||||||
|
}
|
||||||
if info['age_restricted'] or info['player_urls_missing']:
|
if info['age_restricted'] or info['player_urls_missing']:
|
||||||
if info['age_restricted']:
|
if info['age_restricted']:
|
||||||
print('Age restricted video. Fetching /youtubei/v1/player page')
|
print('Age restricted video. Fetching /youtubei/v1/player page')
|
||||||
else:
|
else:
|
||||||
print('Missing player. Fetching /youtubei/v1/player page')
|
print('Missing player. Fetching /youtubei/v1/player page')
|
||||||
|
context['client']['clientScreen'] = 'EMBED'
|
||||||
|
else:
|
||||||
|
print('Fetching /youtubei/v1/player page')
|
||||||
|
|
||||||
# https://github.com/yt-dlp/yt-dlp/issues/574#issuecomment-887171136
|
# https://github.com/yt-dlp/yt-dlp/issues/574#issuecomment-887171136
|
||||||
# ANDROID is used instead because its urls don't require decryption
|
# ANDROID is used instead because its urls don't require decryption
|
||||||
@ -371,19 +384,7 @@ def extract_info(video_id, use_invidious, playlist_id=None, index=None):
|
|||||||
url += '?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8'
|
url += '?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8'
|
||||||
data = {
|
data = {
|
||||||
'videoId': video_id,
|
'videoId': video_id,
|
||||||
'context': {
|
'context': context,
|
||||||
'client': {
|
|
||||||
'clientName': 'ANDROID',
|
|
||||||
'clientVersion': '16.20',
|
|
||||||
'clientScreen': 'EMBED',
|
|
||||||
'gl': 'US',
|
|
||||||
'hl': 'en',
|
|
||||||
},
|
|
||||||
# https://github.com/yt-dlp/yt-dlp/pull/575#issuecomment-887739287
|
|
||||||
'thirdParty': {
|
|
||||||
'embedUrl': 'https://google.com', # Can be any valid URL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
data = json.dumps(data)
|
data = json.dumps(data)
|
||||||
content_header = (('Content-Type', 'application/json'),)
|
content_header = (('Content-Type', 'application/json'),)
|
||||||
@ -391,8 +392,8 @@ def extract_info(video_id, use_invidious, playlist_id=None, index=None):
|
|||||||
url, data=data, headers=util.mobile_ua + content_header,
|
url, data=data, headers=util.mobile_ua + content_header,
|
||||||
debug_name='youtubei_player',
|
debug_name='youtubei_player',
|
||||||
report_text='Fetched youtubei player page').decode('utf-8')
|
report_text='Fetched youtubei player page').decode('utf-8')
|
||||||
yt_data_extract.update_with_age_restricted_info(info,
|
|
||||||
player_response)
|
yt_data_extract.update_with_age_restricted_info(info, player_response)
|
||||||
|
|
||||||
# signature decryption
|
# signature decryption
|
||||||
decryption_error = decrypt_signatures(info, video_id)
|
decryption_error = decrypt_signatures(info, video_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user