player: integrate ytdl_hook.lua

This commit is contained in:
wm4 2014-11-19 18:51:53 +01:00
parent 0f7df89468
commit 079ecd7f01
7 changed files with 28 additions and 18 deletions

View File

@ -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
-----

View File

@ -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

View File

@ -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,

View File

@ -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;

View File

@ -64,6 +64,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}
};

View File

@ -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])

View File

@ -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" ),