mirror of
https://github.com/mpv-player/mpv
synced 2025-02-21 07:16:56 +00:00
player: fix previous commit
OK, this made the --sub-paths and --audio-file-paths synonyms, which is not what we wanted. Actually restrict the type of file loaded as well. Really fixes #2632.
This commit is contained in:
parent
0710ced079
commit
7dff6a2842
@ -87,7 +87,7 @@ static struct bstr guess_lang_from_filename(struct bstr name)
|
||||
static void append_dir_subtitles(struct mpv_global *global,
|
||||
struct subfn **slist, int *nsub,
|
||||
struct bstr path, const char *fname,
|
||||
int limit_fuzziness)
|
||||
int limit_fuzziness, int limit_type)
|
||||
{
|
||||
void *tmpmem = talloc_new(NULL);
|
||||
struct MPOpts *opts = global->opts;
|
||||
@ -136,7 +136,7 @@ static void append_dir_subtitles(struct mpv_global *global,
|
||||
break;
|
||||
}
|
||||
|
||||
if (fuzz < 0)
|
||||
if (fuzz < 0 || (limit_type >= 0 && limit_type != type))
|
||||
goto next_sub;
|
||||
|
||||
// we have a (likely) subtitle file
|
||||
@ -228,18 +228,20 @@ static void filter_subidx(struct subfn **slist, int *nsub)
|
||||
|
||||
static void load_paths(struct mpv_global *global, struct subfn **slist,
|
||||
int *nsubs, const char *fname, char **paths,
|
||||
char *cfg_path)
|
||||
char *cfg_path, int type)
|
||||
{
|
||||
for (int i = 0; paths && paths[i]; i++) {
|
||||
char *path = mp_path_join_bstr(*slist, mp_dirname(fname),
|
||||
bstr0(paths[i]));
|
||||
append_dir_subtitles(global, slist, nsubs, bstr0(path), fname, 0);
|
||||
append_dir_subtitles(global, slist, nsubs, bstr0(path), fname, 0, type);
|
||||
}
|
||||
|
||||
// Load subtitles in ~/.mpv/sub (or similar) limiting sub fuzziness
|
||||
char *mp_subdir = mp_find_config_file(NULL, global, cfg_path);
|
||||
if (mp_subdir)
|
||||
append_dir_subtitles(global, slist, nsubs, bstr0(mp_subdir), fname, 1);
|
||||
if (mp_subdir) {
|
||||
append_dir_subtitles(global, slist, nsubs, bstr0(mp_subdir), fname, 1,
|
||||
type);
|
||||
}
|
||||
talloc_free(mp_subdir);
|
||||
}
|
||||
|
||||
@ -252,14 +254,18 @@ struct subfn *find_external_files(struct mpv_global *global, const char *fname)
|
||||
int n = 0;
|
||||
|
||||
// Load subtitles from current media directory
|
||||
append_dir_subtitles(global, &slist, &n, mp_dirname(fname), fname, 0);
|
||||
append_dir_subtitles(global, &slist, &n, mp_dirname(fname), fname, 0, -1);
|
||||
|
||||
// Load subtitles in dirs specified by sub-paths option
|
||||
if (opts->sub_auto >= 0)
|
||||
load_paths(global, &slist, &n, fname, opts->sub_paths, "sub/");
|
||||
if (opts->sub_auto >= 0) {
|
||||
load_paths(global, &slist, &n, fname, opts->sub_paths, "sub/",
|
||||
STREAM_SUB);
|
||||
}
|
||||
|
||||
if (opts->audiofile_auto >= 0)
|
||||
load_paths(global, &slist, &n, fname, opts->audiofile_paths, "audio/");
|
||||
if (opts->audiofile_auto >= 0) {
|
||||
load_paths(global, &slist, &n, fname, opts->audiofile_paths, "audio/",
|
||||
STREAM_AUDIO);
|
||||
}
|
||||
|
||||
// Sort by name for filter_subidx()
|
||||
qsort(slist, n, sizeof(*slist), compare_sub_filename);
|
||||
|
Loading…
Reference in New Issue
Block a user