>From 85700d51fce7646ce56b854f41d160d3e331208f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Sat, 20 Nov 2010 21:08:06 +0100 Subject: [PATCH 3/3] Add subdirs option. --- DOCS/man/en/mplayer.1 | 31 ++++++++++++++++++++++--------- cfg-common.h | 1 + mencoder.c | 1 + mpcommon.h | 1 + mplayer.c | 1 + sub/subreader.c | 12 ++++++++++++ 6 files changed, 38 insertions(+), 9 deletions(-) diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1 index 71d234c..3509a00 100644 --- a/DOCS/man/en/mplayer.1 +++ b/DOCS/man/en/mplayer.1 @@ -2558,7 +2558,7 @@ exact match .IPs 1 Load all subs containing movie name. .IPs 2 -Load all subs in the current directory. +Load all subs in the current and \-subdirs directories. .RE .PD 1 . @@ -2625,6 +2625,27 @@ Guess the encoding for Polish, fall back on cp1250. .PD 1 . .TP +.B \-subdirs +Specify extra subtitles directories to track in the media directory. +.sp 1 +.I EXAMPLE: +Assuming that /path/\:to/\:movie/\:movie.avi is played and \-subdirs +sub,subtitles,/tmp/subs is specified, MPlayer searches for subtitles files in these +directories: +.RSs +/path/\:to/\:movie/ +.br +/path/\:to/\:movie/\:sub/ +.br +/path/\:to/\:movie/\:subtitles/ +.br +/tmp/\:subs/ +.br +~/.mplayer/\:sub/ +.RE +.PD 1 +. +.TP .B \-subdelay Delays subtitles by seconds. Can be negative. @@ -11737,14 +11758,6 @@ font directory (There must be a font.desc file and files with .RAW extension.) .TP ~/.mplayer/\:DVDkeys/ cached CSS keys -. -.TP -Assuming that /path/\:to/\:movie.avi is played, MPlayer searches for sub files -in this order: -.RS -/path/\:to/\:movie.sub -.br -~/.mplayer/\:sub/\:movie.sub .RE .PD 1 . diff --git a/cfg-common.h b/cfg-common.h index c6dfef0..d50ebe2 100644 --- a/cfg-common.h +++ b/cfg-common.h @@ -562,6 +562,7 @@ const m_option_t common_opts[] = { // ------------------------- subtitles options -------------------- {"sub", &sub_name, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL}, + {"subdirs", &sub_dirs, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL}, #ifdef CONFIG_FRIBIDI {"fribidi-charset", &fribidi_charset, CONF_TYPE_STRING, 0, 0, 0, NULL}, {"flip-hebrew", &flip_hebrew, CONF_TYPE_FLAG, 0, 0, 1, NULL}, diff --git a/mencoder.c b/mencoder.c index 6efe907..403fbac 100644 --- a/mencoder.c +++ b/mencoder.c @@ -179,6 +179,7 @@ char *font_name=NULL; char *sub_font_name=NULL; float font_factor=0.75; char **sub_name=NULL; +char **sub_dirs = NULL; float sub_delay=0; float sub_fps=0; int sub_auto = 0; diff --git a/mpcommon.h b/mpcommon.h index 19110d6..4a2147e 100644 --- a/mpcommon.h +++ b/mpcommon.h @@ -35,6 +35,7 @@ extern int sub_auto; extern float sub_delay; extern float sub_fps; extern char **sub_name; +extern char **sub_dirs; extern char *font_name; extern char *sub_font_name; extern char *audio_lang; diff --git a/mplayer.c b/mplayer.c index 05529e6..97a1d9c 100644 --- a/mplayer.c +++ b/mplayer.c @@ -292,6 +292,7 @@ char *font_name=NULL; char *sub_font_name=NULL; float font_factor=0.75; char **sub_name=NULL; +char **sub_dirs = NULL; float sub_delay=0; float sub_fps=0; int sub_auto = 1; diff --git a/sub/subreader.c b/sub/subreader.c index 1c38412..715af74 100644 --- a/sub/subreader.c +++ b/sub/subreader.c @@ -2123,6 +2123,18 @@ void load_subtitles(const char *fname, int fps, void add_f(char *, float, int)) // Load subtitles from current media directory track_sub_directory("", fname, &slist); + // Load subtitles in dirs specified by subdirs option + if (sub_dirs) + for (i = 0; sub_dirs[i]; i++) +#if HAVE_DOS_PATHS + if (sub_dirs[i][1] == ':') +#else + if (sub_dirs[i][0] == '/') +#endif + append_dir_subtitles(&slist, sub_dirs[i], fname, 0); + else + track_sub_directory(sub_dirs[i], fname, &slist); + // Load subtitles in ~/.mplayer/sub mp_subdir = get_path("sub/"); if (mp_subdir) -- 1.7.3.3