mirror of https://github.com/mpv-player/mpv
player: integrate ytdl_hook.lua
This commit is contained in:
parent
0f7df89468
commit
079ecd7f01
|
@ -422,6 +422,18 @@ Program Behavior
|
||||||
|
|
||||||
May be dangerous if playing from untrusted media.
|
May be dangerous if playing from untrusted media.
|
||||||
|
|
||||||
|
``--ytdl``, ``--no-ytdl``
|
||||||
|
Enable the youtube-dl hook-script. It will look at the input URL, and will
|
||||||
|
play the video located on the website. This works with many streaming sites,
|
||||||
|
not just the one the scripts are named after. This requires a recent version
|
||||||
|
of youtube-dl to be installed on the system.
|
||||||
|
|
||||||
|
If the script can't do anything with an URL, it will do nothing.
|
||||||
|
|
||||||
|
Currently disabled by default, because youtube-dl's generic extractor can
|
||||||
|
get stuck on some URL, preventing playback.
|
||||||
|
|
||||||
|
(Note: this is the replacement for the now removed libquvi support.)
|
||||||
|
|
||||||
Video
|
Video
|
||||||
-----
|
-----
|
||||||
|
|
|
@ -386,6 +386,7 @@ player/lua/%.inc: TOOLS/file2string.pl player/lua/%.lua
|
||||||
player/lua.c: player/lua/defaults.inc \
|
player/lua.c: player/lua/defaults.inc \
|
||||||
player/lua/assdraw.inc \
|
player/lua/assdraw.inc \
|
||||||
player/lua/osc.inc \
|
player/lua/osc.inc \
|
||||||
|
player/lua/ytdl_hook.inc \
|
||||||
player/lua/options.inc
|
player/lua/options.inc
|
||||||
|
|
||||||
etc/_mpv: TOOLS/zsh.pl ./mpv
|
etc/_mpv: TOOLS/zsh.pl ./mpv
|
||||||
|
@ -490,6 +491,7 @@ clean:
|
||||||
-$(RM) player/lua/defaults.inc
|
-$(RM) player/lua/defaults.inc
|
||||||
-$(RM) player/lua/assdraw.inc
|
-$(RM) player/lua/assdraw.inc
|
||||||
-$(RM) player/lua/osc.inc
|
-$(RM) player/lua/osc.inc
|
||||||
|
-$(RM) player/lua/ytdl_hook.inc
|
||||||
-$(RM) player/lua/options.inc
|
-$(RM) player/lua/options.inc
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
|
|
|
@ -130,6 +130,7 @@ const m_option_t mp_opts[] = {
|
||||||
OPT_STRINGLIST("lua", lua_files, CONF_GLOBAL | M_OPT_FILE),
|
OPT_STRINGLIST("lua", lua_files, CONF_GLOBAL | M_OPT_FILE),
|
||||||
OPT_KEYVALUELIST("lua-opts", lua_opts, M_OPT_GLOBAL),
|
OPT_KEYVALUELIST("lua-opts", lua_opts, M_OPT_GLOBAL),
|
||||||
OPT_FLAG("osc", lua_load_osc, CONF_GLOBAL),
|
OPT_FLAG("osc", lua_load_osc, CONF_GLOBAL),
|
||||||
|
OPT_FLAG("ytdl", lua_load_ytdl, CONF_GLOBAL),
|
||||||
OPT_FLAG("load-scripts", auto_load_scripts, CONF_GLOBAL),
|
OPT_FLAG("load-scripts", auto_load_scripts, CONF_GLOBAL),
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -610,6 +611,7 @@ const struct MPOpts mp_default_opts = {
|
||||||
.osd_scale_by_window = 1,
|
.osd_scale_by_window = 1,
|
||||||
#if HAVE_LUA
|
#if HAVE_LUA
|
||||||
.lua_load_osc = 1,
|
.lua_load_osc = 1,
|
||||||
|
.lua_load_ytdl = 0,
|
||||||
#endif
|
#endif
|
||||||
.auto_load_scripts = 1,
|
.auto_load_scripts = 1,
|
||||||
.loop_times = -1,
|
.loop_times = -1,
|
||||||
|
|
|
@ -61,6 +61,7 @@ typedef struct MPOpts {
|
||||||
char **lua_files;
|
char **lua_files;
|
||||||
char **lua_opts;
|
char **lua_opts;
|
||||||
int lua_load_osc;
|
int lua_load_osc;
|
||||||
|
int lua_load_ytdl;
|
||||||
int auto_load_scripts;
|
int auto_load_scripts;
|
||||||
|
|
||||||
struct m_obj_settings *audio_driver_list, *ao_defs;
|
struct m_obj_settings *audio_driver_list, *ao_defs;
|
||||||
|
|
|
@ -64,6 +64,9 @@ static const char * const builtin_lua_scripts[][2] = {
|
||||||
},
|
},
|
||||||
{"@osc.lua",
|
{"@osc.lua",
|
||||||
# include "player/lua/osc.inc"
|
# include "player/lua/osc.inc"
|
||||||
|
},
|
||||||
|
{"@ytdl_hook.lua",
|
||||||
|
# include "player/lua/ytdl_hook.inc"
|
||||||
},
|
},
|
||||||
{0}
|
{0}
|
||||||
};
|
};
|
||||||
|
|
|
@ -177,6 +177,8 @@ void mp_load_scripts(struct MPContext *mpctx)
|
||||||
// Load scripts from options
|
// Load scripts from options
|
||||||
if (mpctx->opts->lua_load_osc)
|
if (mpctx->opts->lua_load_osc)
|
||||||
mp_load_script(mpctx, "@osc.lua");
|
mp_load_script(mpctx, "@osc.lua");
|
||||||
|
if (mpctx->opts->lua_load_ytdl)
|
||||||
|
mp_load_script(mpctx, "@ytdl_hook.lua");
|
||||||
char **files = mpctx->opts->lua_files;
|
char **files = mpctx->opts->lua_files;
|
||||||
for (int n = 0; files && files[n]; n++) {
|
for (int n = 0; files && files[n]; n++) {
|
||||||
if (files[n][0])
|
if (files[n][0])
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import re
|
import re
|
||||||
|
import os
|
||||||
|
|
||||||
def _add_rst_manual_dependencies(ctx):
|
def _add_rst_manual_dependencies(ctx):
|
||||||
manpage_sources_basenames = """
|
manpage_sources_basenames = """
|
||||||
|
@ -56,21 +57,11 @@ def build(ctx):
|
||||||
source = "sub/osd_font.otf",
|
source = "sub/osd_font.otf",
|
||||||
target = "sub/osd_font.h")
|
target = "sub/osd_font.h")
|
||||||
|
|
||||||
ctx.file2string(
|
lua_files = ["defaults.lua", "assdraw.lua", "options.lua", "osc.lua",
|
||||||
source = "player/lua/defaults.lua",
|
"ytdl_hook.lua"]
|
||||||
target = "player/lua/defaults.inc")
|
for fn in lua_files:
|
||||||
|
fn = "player/lua/" + fn
|
||||||
ctx.file2string(
|
ctx.file2string(source = fn, target = os.path.splitext(fn)[0] + ".inc")
|
||||||
source = "player/lua/assdraw.lua",
|
|
||||||
target = "player/lua/assdraw.inc")
|
|
||||||
|
|
||||||
ctx.file2string(
|
|
||||||
source = "player/lua/options.lua",
|
|
||||||
target = "player/lua/options.inc")
|
|
||||||
|
|
||||||
ctx.file2string(
|
|
||||||
source = "player/lua/osc.lua",
|
|
||||||
target = "player/lua/osc.inc")
|
|
||||||
|
|
||||||
ctx.matroska_header(
|
ctx.matroska_header(
|
||||||
source = "demux/ebml.c demux/demux_mkv.c",
|
source = "demux/ebml.c demux/demux_mkv.c",
|
||||||
|
@ -433,7 +424,6 @@ def build(ctx):
|
||||||
)
|
)
|
||||||
for f in ['example.conf', 'input.conf', 'mplayer-input.conf', \
|
for f in ['example.conf', 'input.conf', 'mplayer-input.conf', \
|
||||||
'restore-old-bindings.conf']:
|
'restore-old-bindings.conf']:
|
||||||
import os
|
|
||||||
ctx.install_as(os.path.join(ctx.env.DOCDIR, f),
|
ctx.install_as(os.path.join(ctx.env.DOCDIR, f),
|
||||||
os.path.join('etc/', f))
|
os.path.join('etc/', f))
|
||||||
|
|
||||||
|
@ -441,7 +431,6 @@ def build(ctx):
|
||||||
build_static = ctx.dependency_satisfied('libmpv-static')
|
build_static = ctx.dependency_satisfied('libmpv-static')
|
||||||
if build_shared or build_static:
|
if build_shared or build_static:
|
||||||
if build_shared:
|
if build_shared:
|
||||||
import os
|
|
||||||
waftoolsdir = os.path.join(os.path.dirname(__file__), "waftools")
|
waftoolsdir = os.path.join(os.path.dirname(__file__), "waftools")
|
||||||
ctx.load("syms", tooldir=waftoolsdir)
|
ctx.load("syms", tooldir=waftoolsdir)
|
||||||
vre = '^#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION\((.*), (.*)\)$'
|
vre = '^#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION\((.*), (.*)\)$'
|
||||||
|
@ -496,7 +485,6 @@ def build(ctx):
|
||||||
ctx.install_as(ctx.env.LIBDIR + '/pkgconfig/mpv.pc', 'libmpv/mpv.pc')
|
ctx.install_as(ctx.env.LIBDIR + '/pkgconfig/mpv.pc', 'libmpv/mpv.pc')
|
||||||
|
|
||||||
if ctx.dependency_satisfied('client-api-examples'):
|
if ctx.dependency_satisfied('client-api-examples'):
|
||||||
import os
|
|
||||||
# This assumes all examples are single-file (as examples should be)
|
# This assumes all examples are single-file (as examples should be)
|
||||||
examples_sources = [
|
examples_sources = [
|
||||||
( "simple.c" ),
|
( "simple.c" ),
|
||||||
|
|
Loading…
Reference in New Issue