aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/watch.py
diff options
context:
space:
mode:
Diffstat (limited to 'youtube/watch.py')
-rw-r--r--youtube/watch.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/youtube/watch.py b/youtube/watch.py
index 46cfdf5..53836aa 100644
--- a/youtube/watch.py
+++ b/youtube/watch.py
@@ -25,15 +25,19 @@ INNERTUBE_CLIENTS = {
'INNERTUBE_API_KEY': 'AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w',
'INNERTUBE_CONTEXT': {
'client': {
+ 'hl': 'en',
+ 'gl': 'US',
'clientName': 'ANDROID',
'clientVersion': '17.31.35',
+ 'osName': 'Android',
+ 'osVersion': '12',
'androidSdkVersion': 31,
- 'userAgent': 'com.google.android.youtube/17.31.35 (Linux; U; Android 11) gzip'
+ 'userAgent': 'com.google.android.youtube/17.31.35 (Linux; U; Android 12) gzip'
},
# https://github.com/yt-dlp/yt-dlp/pull/575#issuecomment-887739287
- 'thirdParty': {
- 'embedUrl': 'https://google.com', # Can be any valid URL
- }
+ #'thirdParty': {
+ # 'embedUrl': 'https://google.com', # Can be any valid URL
+ #}
},
'INNERTUBE_CONTEXT_CLIENT_NAME': 3,
'REQUIRE_JS_PLAYER': False,
@@ -45,6 +49,8 @@ INNERTUBE_CLIENTS = {
'INNERTUBE_API_KEY': 'AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8',
'INNERTUBE_CONTEXT': {
'client': {
+ 'hl': 'en',
+ 'gl': 'US',
'clientName': 'TVHTML5_SIMPLY_EMBEDDED_PLAYER',
'clientVersion': '2.0',
},
@@ -378,17 +384,19 @@ def _add_to_error(info, key, additional_message):
else:
info[key] = additional_message
+
def fetch_player_response(client, video_id):
client_params = INNERTUBE_CLIENTS[client]
context = client_params['INNERTUBE_CONTEXT']
key = client_params['INNERTUBE_API_KEY']
- host = client_params.get('INNERTUBE_HOST') or 'youtubei.googleapis.com'
+ host = client_params.get('INNERTUBE_HOST') or 'www.youtube.com'
user_agent = context['client'].get('userAgent') or util.mobile_user_agent
url = 'https://' + host + '/youtubei/v1/player?key=' + key
data = {
'videoId': video_id,
'context': context,
+ 'params': '8AEB',
}
data = json.dumps(data)
headers = (('Content-Type', 'application/json'),('User-Agent', user_agent))
@@ -440,9 +448,7 @@ def extract_info(video_id, use_invidious, playlist_id=None, index=None):
util.check_gevent_exceptions(*tasks)
info, player_response = tasks[0].value, tasks[1].value
- if yt_data_extract.requires_decryption(info):
- print('Encrypted. Replacing with URLs from Android client')
- yt_data_extract.update_with_new_urls(info, player_response)
+ yt_data_extract.update_with_new_urls(info, player_response)
# Age restricted video, retry
if info['age_restricted'] or info['player_urls_missing']:
@@ -626,8 +632,6 @@ def get_storyboard_vtt():
time_table = {'h': 3600, 'm': 60, 's': 1}
-
-
@yt_app.route('/watch')
@yt_app.route('/embed')
@yt_app.route('/embed/<video_id>')
@@ -745,7 +749,6 @@ def get_watch_page(video_id=None):
pair_sources = source_info['pair_sources']
uni_idx, pair_idx = source_info['uni_idx'], source_info['pair_idx']
-
pair_quality = yt_data_extract.deep_get(pair_sources, pair_idx, 'quality')
uni_quality = yt_data_extract.deep_get(uni_sources, uni_idx, 'quality')
@@ -862,7 +865,7 @@ def get_watch_page(video_id=None):
'related': info['related_videos'],
'playability_error': info['playability_error'],
},
- font_family=youtube.font_choices[settings.font], # for embed page
+ font_family = youtube.font_choices[settings.font], # for embed page
**source_info,
using_pair_sources = using_pair_sources,
)