summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-11-19 18:51:53 +0100
committerwm4 <wm4@nowhere>2014-11-19 18:59:38 +0100
commit079ecd7f017be7528ab597e5db36042a0eecee0d (patch)
tree2518efcadb7d06971ef26b4de1636bfa1206b850
parent0f7df894688d7d2d4b5745944d9b84aeb512f1ae (diff)
downloadmpv-079ecd7f017be7528ab597e5db36042a0eecee0d.tar.bz2
mpv-079ecd7f017be7528ab597e5db36042a0eecee0d.tar.xz
player: integrate ytdl_hook.lua
-rw-r--r--DOCS/man/options.rst12
-rw-r--r--old-makefile2
-rw-r--r--options/options.c2
-rw-r--r--options/options.h1
-rw-r--r--player/lua.c3
-rw-r--r--player/scripting.c2
-rw-r--r--wscript_build.py24
7 files changed, 28 insertions, 18 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index efc0228a76..b10db21a75 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -422,6 +422,18 @@ Program Behavior
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
-----
diff --git a/old-makefile b/old-makefile
index c7abacf96e..aa73c41050 100644
--- a/old-makefile
+++ b/old-makefile
@@ -386,6 +386,7 @@ player/lua/%.inc: TOOLS/file2string.pl player/lua/%.lua
player/lua.c: player/lua/defaults.inc \
player/lua/assdraw.inc \
player/lua/osc.inc \
+ player/lua/ytdl_hook.inc \
player/lua/options.inc
etc/_mpv: TOOLS/zsh.pl ./mpv
@@ -490,6 +491,7 @@ clean:
-$(RM) player/lua/defaults.inc
-$(RM) player/lua/assdraw.inc
-$(RM) player/lua/osc.inc
+ -$(RM) player/lua/ytdl_hook.inc
-$(RM) player/lua/options.inc
distclean: clean
diff --git a/options/options.c b/options/options.c
index 1f6e0ae377..6dbf4164e2 100644
--- a/options/options.c
+++ b/options/options.c
@@ -130,6 +130,7 @@ const m_option_t mp_opts[] = {
OPT_STRINGLIST("lua", lua_files, CONF_GLOBAL | M_OPT_FILE),
OPT_KEYVALUELIST("lua-opts", lua_opts, M_OPT_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),
#endif
@@ -610,6 +611,7 @@ const struct MPOpts mp_default_opts = {
.osd_scale_by_window = 1,
#if HAVE_LUA
.lua_load_osc = 1,
+ .lua_load_ytdl = 0,
#endif
.auto_load_scripts = 1,
.loop_times = -1,
diff --git a/options/options.h b/options/options.h
index 94d78ac6a0..5885f689f8 100644
--- a/options/options.h
+++ b/options/options.h
@@ -61,6 +61,7 @@ typedef struct MPOpts {
char **lua_files;
char **lua_opts;
int lua_load_osc;
+ int lua_load_ytdl;
int auto_load_scripts;
struct m_obj_settings *audio_driver_list, *ao_defs;
diff --git a/player/lua.c b/player/lua.c
index 699c928e87..8a2e3ec925 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -65,6 +65,9 @@ static const char * const builtin_lua_scripts[][2] = {
{"@osc.lua",
# include "player/lua/osc.inc"
},
+ {"@ytdl_hook.lua",
+# include "player/lua/ytdl_hook.inc"
+ },
{0}
};
diff --git a/player/scripting.c b/player/scripting.c
index 982d64a3cd..f2ddcec2aa 100644
--- a/player/scripting.c
+++ b/player/scripting.c
@@ -177,6 +177,8 @@ void mp_load_scripts(struct MPContext *mpctx)
// Load scripts from options
if (mpctx->opts->lua_load_osc)
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;
for (int n = 0; files && files[n]; n++) {
if (files[n][0])
diff --git a/wscript_build.py b/wscript_build.py
index 4fefb87004..4bc703bc07 100644
--- a/wscript_build.py
+++ b/wscript_build.py
@@ -1,4 +1,5 @@
import re
+import os
def _add_rst_manual_dependencies(ctx):
manpage_sources_basenames = """
@@ -56,21 +57,11 @@ def build(ctx):
source = "sub/osd_font.otf",
target = "sub/osd_font.h")
- ctx.file2string(
- source = "player/lua/defaults.lua",
- target = "player/lua/defaults.inc")
-
- ctx.file2string(
- 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")
+ lua_files = ["defaults.lua", "assdraw.lua", "options.lua", "osc.lua",
+ "ytdl_hook.lua"]
+ for fn in lua_files:
+ fn = "player/lua/" + fn
+ ctx.file2string(source = fn, target = os.path.splitext(fn)[0] + ".inc")
ctx.matroska_header(
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', \
'restore-old-bindings.conf']:
- import os
ctx.install_as(os.path.join(ctx.env.DOCDIR, f),
os.path.join('etc/', f))
@@ -441,7 +431,6 @@ def build(ctx):
build_static = ctx.dependency_satisfied('libmpv-static')
if build_shared or build_static:
if build_shared:
- import os
waftoolsdir = os.path.join(os.path.dirname(__file__), "waftools")
ctx.load("syms", tooldir=waftoolsdir)
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')
if ctx.dependency_satisfied('client-api-examples'):
- import os
# This assumes all examples are single-file (as examples should be)
examples_sources = [
( "simple.c" ),