fix: use exclusively tv player for age-restricted videos

also filter out DRC audio
This commit is contained in:
2025-11-20 17:54:41 +01:00
parent eebf434f3e
commit d1f381220d
2 changed files with 8 additions and 4 deletions

View File

@@ -162,13 +162,13 @@ def extract(url: str, getcomments=False, maxcomments="", manifest_fix=False, use
match use_cookies: match use_cookies:
case "global": case "global":
ytdl_context['cookiefile'] = ythdd_globals.config['extractor']['cookies_path'] ytdl_context['cookiefile'] = ythdd_globals.config['extractor']['cookies_path']
ytdl_context['extractor_args']['youtube']['player_client'] = ['mweb', 'tv'] ytdl_context['extractor_args']['youtube']['player_client'] = ['tv']
if not deno_path: if not deno_path:
print("FATAL ERROR: deno path is required for playback using cookies!") print("FATAL ERROR: deno path is required for playback using cookies!")
ytdl_context['js_runtimes']['deno']['path'] = deno_path if deno_path else "" ytdl_context['js_runtimes']['deno']['path'] = deno_path if deno_path else ""
case "agegated": case "agegated":
ytdl_context['cookiefile'] = ythdd_globals.config['extractor']['age_restricted_cookies_path'] ytdl_context['cookiefile'] = ythdd_globals.config['extractor']['age_restricted_cookies_path']
ytdl_context['extractor_args']['youtube']['player_client'] = ['mweb', 'tv'] ytdl_context['extractor_args']['youtube']['player_client'] = ['tv']
if not deno_path: if not deno_path:
print("FATAL ERROR: deno path is required for playback of age-restricted content!") print("FATAL ERROR: deno path is required for playback of age-restricted content!")
ytdl_context['js_runtimes']['deno']['path'] = deno_path if deno_path else "" ytdl_context['js_runtimes']['deno']['path'] = deno_path if deno_path else ""

View File

@@ -290,8 +290,11 @@ def videos(data):
continue continue
if video_stream["format_id"] == "18": # todo: do this dynamically if video_stream["format_id"] == "18": # todo: do this dynamically
initial_fstreams_y[int(video_stream["format_id"])] = video_stream initial_fstreams_y[int(video_stream["format_id"])] = video_stream
else: elif video_stream["format_id"].isdigit():
# filter out DRC audio
initial_astreams_y[int(video_stream["format_id"])] = video_stream initial_astreams_y[int(video_stream["format_id"])] = video_stream
else:
continue
# format streams # format streams
for video_stream in wdata_streams["formats"]: for video_stream in wdata_streams["formats"]:
@@ -315,6 +318,7 @@ def videos(data):
hls_url = safeTraverse(ydata, ["url"], default="ythdd: unable to retrieve stream url") hls_url = safeTraverse(ydata, ["url"], default="ythdd: unable to retrieve stream url")
if age_restricted: if age_restricted:
if not adaptive_formats:
adaptive_formats = [{"url": f"http://a/?expire={int(time_start + 5.9 * 60 * 60)}", "itag": "18", "type": "", "clen": "0", "lmt": "", "projectionType": "RECTANGULAR"}] # same as above adaptive_formats = [{"url": f"http://a/?expire={int(time_start + 5.9 * 60 * 60)}", "itag": "18", "type": "", "clen": "0", "lmt": "", "projectionType": "RECTANGULAR"}] # same as above
description += " \n(ythdd: this video is age-restricted and thus only available in 360p - itag 18)" description += " \n(ythdd: this video is age-restricted and thus only available in 360p - itag 18)"
description_html += "<br/>(ythdd: this video is age-restricted and thus only available in 360p - itag 18)" description_html += "<br/>(ythdd: this video is age-restricted and thus only available in 360p - itag 18)"