[PATCH 2/2] Add subdirs option.

Clément Bœsch ubitux at gmail.com
Sat Nov 20 21:08:06 CET 2010


---
 DOCS/man/en/mplayer.1 |   31 ++++++++++++++++++++++---------
 cfg-common.h          |    1 +
 mencoder.c            |    1 +
 mpcommon.h            |    1 +
 mplayer.c             |    1 +
 sub/subreader.c       |   13 +++++++++++++
 6 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1
index 02ad9d6..59eba19 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 <dirname1,dirname2,...>
+Specify extra subtitle 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 subtitle 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 <sec>
 Delays subtitles by <sec> seconds.
 Can be negative.
@@ -11740,14 +11761,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 b821730..c3271b9 100644
--- a/mpcommon.h
+++ b/mpcommon.h
@@ -37,6 +37,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 8a2d7a2..c17aec4 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -289,6 +289,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 1e19b51..08f263e 100644
--- a/sub/subreader.c
+++ b/sub/subreader.c
@@ -2079,6 +2079,19 @@ void load_subtitles(const char *fname, int fps, void add_f(char *, float, int))
     append_dir_subtitles(&slist, path, fname, 0);
     free(path);
 
+    // Load subtitles in dirs specified by subdirs option
+    if (sub_dirs) {
+        for (i = 0; sub_dirs[i]; i++) {
+            path = mp_path_join(fname, sub_dirs[i]);
+            if (!path) {
+                free(slist.subs);
+                return;
+            }
+            append_dir_subtitles(&slist, path, fname, 0);
+            free(path);
+        }
+    }
+
     // Load subtitles in ~/.mplayer/sub limiting sub fuzziness
     mp_subdir = get_path("sub/");
     if (mp_subdir)
-- 
1.7.3.4


--ibTvN161/egqYuK8--


More information about the MPlayer-dev-eng mailing list