summaryrefslogtreecommitdiffstats
path: root/sub
diff options
context:
space:
mode:
authorClément Bœsch <ubitux@gmail.com>2011-03-03 11:31:12 +0100
committerUoti Urpala <uau@mplayer2.org>2011-04-20 04:22:52 +0300
commit1c6995d76cfb26a1a87dd4d23a6260e9cf7ecb62 (patch)
tree246bccc917c11127bfb090cc509e6e0ea7e06f4c /sub
parent2db33ab48cfa7858dacd2872b7e6b6b0c67b7214 (diff)
downloadmpv-1c6995d76cfb26a1a87dd4d23a6260e9cf7ecb62.tar.bz2
mpv-1c6995d76cfb26a1a87dd4d23a6260e9cf7ecb62.tar.xz
subs: options: add -sub-paths
Diffstat (limited to 'sub')
-rw-r--r--sub/find_subfiles.c28
-rw-r--r--sub/find_subfiles.h6
2 files changed, 29 insertions, 5 deletions
diff --git a/sub/find_subfiles.c b/sub/find_subfiles.c
index a5834ab733..85ea47b0c2 100644
--- a/sub/find_subfiles.c
+++ b/sub/find_subfiles.c
@@ -4,6 +4,7 @@
#include <ctype.h>
#include "mp_msg.h"
+#include "options.h"
#include "path.h"
#include "mpcommon.h"
#include "sub/find_subfiles.h"
@@ -241,14 +242,24 @@ static void append_dir_subtitles(struct subfn **slist, int *nsub,
free(tmpresult);
}
-char **find_text_subtitles(const char *fname)
+char **find_text_subtitles(struct MPOpts *opts, const char *fname)
{
+ char **subnames = NULL;
struct subfn *slist = talloc_array_ptrtype(NULL, slist, 1);
int n = 0;
// Load subtitles from current media directory
append_dir_subtitles(&slist, &n, mp_dirname(fname), fname, 0);
+ // Load subtitles in dirs specified by sub-paths option
+ if (opts->sub_paths) {
+ for (int i = 0; opts->sub_paths[i]; i++) {
+ char *path = mp_path_join(slist, mp_dirname(fname),
+ BSTR(opts->sub_paths[i]));
+ append_dir_subtitles(&slist, &n, BSTR(path), fname, 0);
+ }
+ }
+
// Load subtitles in ~/.mplayer/sub limiting sub fuzziness
char *mp_subdir = get_path("sub/");
if (mp_subdir)
@@ -258,7 +269,7 @@ char **find_text_subtitles(const char *fname)
// Sort subs by priority and append them
qsort(slist, n, sizeof(*slist), compare_sub_priority);
- char **subnames = talloc_array_ptrtype(NULL, subnames, n);
+ subnames = talloc_array_ptrtype(NULL, subnames, n);
for (int i = 0; i < n; i++)
subnames[i] = talloc_strdup(subnames, slist[i].fname);
@@ -266,7 +277,7 @@ char **find_text_subtitles(const char *fname)
return subnames;
}
-char **find_vob_subtitles(const char *fname)
+char **find_vob_subtitles(struct MPOpts *opts, const char *fname)
{
char **vobs = talloc_array_ptrtype(NULL, vobs, 1);
int n = 0;
@@ -278,6 +289,17 @@ char **find_vob_subtitles(const char *fname)
bname.len = pdot;
vobs[n++] = mp_path_join(vobs, mp_dirname(fname), bname);
+ // Potential vobsubs in directories specified by sub-paths option
+ if (opts->sub_paths) {
+ for (int i = 0; opts->sub_paths[i]; i++) {
+ char *path = mp_path_join(NULL, mp_dirname(fname),
+ BSTR(opts->sub_paths[i]));
+ MP_GROW_ARRAY(vobs, n);
+ vobs[n++] = mp_path_join(vobs, BSTR(path), bname);
+ talloc_free(path);
+ }
+ }
+
// Potential vobsub in ~/.mplayer/sub
char *mp_subdir = get_path("sub/");
if (mp_subdir) {
diff --git a/sub/find_subfiles.h b/sub/find_subfiles.h
index c0391277ee..c93164c6f8 100644
--- a/sub/find_subfiles.h
+++ b/sub/find_subfiles.h
@@ -21,7 +21,9 @@
#define MAX_SUBTITLE_FILES 128
-char **find_text_subtitles(const char *fname);
-char **find_vob_subtitles(const char *fname);
+struct MPOpts;
+
+char **find_text_subtitles(struct MPOpts *opts, const char *fname);
+char **find_vob_subtitles(struct MPOpts *opts, const char *fname);
#endif /* MPLAYER_FINDFILES_H */