fix: prefer android_vr extractor by default
this is possibly one of the last known extractors unaffected by signature extraction and decryption shenanigans, which cripples load times on lower-end hardware
This commit is contained in:
@@ -13,6 +13,7 @@ api_key_admin = "CHANGEME" # Empty *admin* API key will autogenerate a random on
|
||||
[extractor]
|
||||
user-agent = "" # Leave empty for default (Firefox ESR).
|
||||
cookies_path = "" # Leave empty for none.
|
||||
preferred_extractor = "" # Leave empty for default (android_vr).
|
||||
|
||||
[proxy]
|
||||
user-agent = "" # Leave empty for default (Firefox ESR).
|
||||
|
||||
@@ -132,21 +132,25 @@ web_context_dict = {
|
||||
def extract(url: str, getcomments=False, maxcomments="", manifest_fix=False):
|
||||
# TODO: check user-agent and cookiefile
|
||||
|
||||
ytdl_context = ytdl_opts.copy()
|
||||
|
||||
if ythdd_globals.config['extractor']['user-agent']:
|
||||
yt_dlp.utils.std_headers['User-Agent'] = ythdd_globals.config['extractor']['user-agent']
|
||||
|
||||
if ythdd_globals.config['extractor']['cookies_path']:
|
||||
ytdl_opts['cookiefile'] = ythdd_globals.config['extractor']['cookies_path']
|
||||
ytdl_context['cookiefile'] = ythdd_globals.config['extractor']['cookies_path']
|
||||
|
||||
if len(url) == 11:
|
||||
url = "https://www.youtube.com/watch?v=" + url
|
||||
if getcomments:
|
||||
ytdl_opts['getcomments'] = True
|
||||
ytdl_context['getcomments'] = True
|
||||
if maxcomments:
|
||||
ytdl_opts['extractor_args']['youtube']['max_comments'] = [maxcomments, "all", "all", "all"]
|
||||
ytdl_context['extractor_args']['youtube']['max_comments'] = [maxcomments, "all", "all", "all"]
|
||||
if manifest_fix:
|
||||
# https://github.com/yt-dlp/yt-dlp/issues/11952#issuecomment-2565802294
|
||||
ytdl_opts['extractor_args']['youtube']['player_client'] = ['default', 'web_safari']
|
||||
ytdl_context['extractor_args']['youtube']['player_client'] = ['default', 'web_safari']
|
||||
elif ythdd_globals.config['extractor']['preferred_extractor']:
|
||||
ytdl_context['extractor_args']['youtube']['player_client'] = [ythdd_globals.config['extractor']['preferred_extractor']]
|
||||
with yt_dlp.YoutubeDL(ytdl_opts) as ytdl:
|
||||
result = ytdl.sanitize_info(ytdl.extract_info(url, download=False))
|
||||
return result
|
||||
|
||||
@@ -372,7 +372,7 @@ def videos(data):
|
||||
if error is not None:
|
||||
return send(500, {"status": "error", "error": error})
|
||||
|
||||
ydata = ythdd_extractor.extract(data[3], manifest_fix=True)
|
||||
ydata = ythdd_extractor.extract(data[3])
|
||||
|
||||
#return send(200, {'ydata': ydata, 'wdata': wdata})
|
||||
#return send(200, {'idata': idata, 'wdata': wdata})
|
||||
|
||||
Reference in New Issue
Block a user