Skip to content

Commit 5b98083

Browse files
committed
ytdl_hook: add ytdl-prefer-srv3 option
1 parent e008a3c commit 5b98083

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

DOCS/man/options.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,15 @@ Program Behavior
10391039
``--ytdl-extract-chapters=<yes|no>``
10401040
Enable chapter extracting from youtube-dl video description (default: yes).
10411041

1042+
``--ytdl-prefer-srv3=<yes|no>``
1043+
Allow youtube-dl to download srv3 subtitles and prefer them over other formats.
1044+
Only available if mpv was compiled with subrandr enabled.
1045+
(default: no)
1046+
1047+
This will prepend `srv3/` to the default allowed ytdl `--sub-format`s.
1048+
Preferring srv3 will make YouTube subtitles display more accurately but
1049+
ignore most of the various `--sub-*` options that override styling.
1050+
10421051
``--js-memory-report=<yes|no>``
10431052
Enable memory reporting for javascript scripts in the stats overlay.
10441053
This is disabled by default because it has an overhead and increases

options/options.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,9 @@ static const m_option_t mp_opts[] = {
557557
{"ytdl-format", OPT_STRING(lua_ytdl_format)},
558558
{"ytdl-raw-options", OPT_KEYVALUELIST(lua_ytdl_raw_options)},
559559
{"ytdl-extract-chapters", OPT_BOOL(lua_ytdl_extract_chapters)},
560+
#if HAVE_SUBRANDR
561+
{"ytdl-prefer-srv3", OPT_BOOL(lua_ytdl_prefer_srv3)},
562+
#endif
560563
{"load-stats-overlay", OPT_BOOL(lua_load_stats),
561564
.flags = UPDATE_BUILTIN_SCRIPTS},
562565
{"load-console", OPT_BOOL(lua_load_console),

options/options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ typedef struct MPOpts {
177177
char *lua_ytdl_format;
178178
char **lua_ytdl_raw_options;
179179
bool lua_ytdl_extract_chapters;
180+
bool lua_ytdl_prefer_srv3;
180181
bool lua_load_stats;
181182
bool lua_load_console;
182183
int lua_load_auto_profiles;

player/lua/ytdl_hook.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,12 +908,13 @@ local function run_ytdl_hook(url)
908908

909909
local format = mp.get_property("options/ytdl-format")
910910
local raw_options = mp.get_property_native("options/ytdl-raw-options")
911+
local prefer_srv3 = mp.get_property_native("options/ytdl-prefer-srv3")
911912
local allsubs = true
912913
local proxy = nil
913914
local use_playlist = false
914915
local wanted_sub_formats = "ass/srt/best"
915916

916-
if has_subrandr then
917+
if prefer_srv3 then
917918
wanted_sub_formats = "srv3/" .. wanted_sub_formats
918919
end
919920

0 commit comments

Comments
 (0)