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:
2025-09-28 07:47:17 +02:00
parent 45073fff67
commit 4a311f185c
3 changed files with 12 additions and 7 deletions

View File

@@ -11,8 +11,9 @@ api_key = "" # Leave empty API key for public access to non-sensitive backend
api_key_admin = "CHANGEME" # Empty *admin* API key will autogenerate a random one every launch. api_key_admin = "CHANGEME" # Empty *admin* API key will autogenerate a random one every launch.
[extractor] [extractor]
user-agent = "" # Leave empty for default (Firefox ESR). user-agent = "" # Leave empty for default (Firefox ESR).
cookies_path = "" # Leave empty for none. cookies_path = "" # Leave empty for none.
preferred_extractor = "" # Leave empty for default (android_vr).
[proxy] [proxy]
user-agent = "" # Leave empty for default (Firefox ESR). user-agent = "" # Leave empty for default (Firefox ESR).

View File

@@ -132,21 +132,25 @@ web_context_dict = {
def extract(url: str, getcomments=False, maxcomments="", manifest_fix=False): def extract(url: str, getcomments=False, maxcomments="", manifest_fix=False):
# TODO: check user-agent and cookiefile # TODO: check user-agent and cookiefile
ytdl_context = ytdl_opts.copy()
if ythdd_globals.config['extractor']['user-agent']: if ythdd_globals.config['extractor']['user-agent']:
yt_dlp.utils.std_headers['User-Agent'] = 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']: 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: if len(url) == 11:
url = "https://www.youtube.com/watch?v=" + url url = "https://www.youtube.com/watch?v=" + url
if getcomments: if getcomments:
ytdl_opts['getcomments'] = True ytdl_context['getcomments'] = True
if maxcomments: 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: if manifest_fix:
# https://github.com/yt-dlp/yt-dlp/issues/11952#issuecomment-2565802294 # 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: with yt_dlp.YoutubeDL(ytdl_opts) as ytdl:
result = ytdl.sanitize_info(ytdl.extract_info(url, download=False)) result = ytdl.sanitize_info(ytdl.extract_info(url, download=False))
return result return result

View File

@@ -372,7 +372,7 @@ def videos(data):
if error is not None: if error is not None:
return send(500, {"status": "error", "error": error}) 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, {'ydata': ydata, 'wdata': wdata})
#return send(200, {'idata': idata, 'wdata': wdata}) #return send(200, {'idata': idata, 'wdata': wdata})