From 1a152eadaf1e2d8beac37d13ba22958b0946db8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Thu, 3 Mar 2011 11:39:18 +0100 Subject: find_subfiles: try to determine if a .sub file is text or vobsub A file with the ambiguous extension .sub could be either VOBsub or MicroDVD. If there's a corresponding .idx file it's certainly VOBsub, so don't add it to the list of potential text subtitles. This will avoid the annoying warning "SUB: Could not determine file format". --- sub/find_subfiles.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'sub') diff --git a/sub/find_subfiles.c b/sub/find_subfiles.c index 85ea47b0c2..31413724a8 100644 --- a/sub/find_subfiles.c +++ b/sub/find_subfiles.c @@ -153,6 +153,20 @@ static void append_dir_subtitles(struct subfn **slist, int *nsub, strcpy_get_ext(tmp_fname_ext, de->d_name); strcpy_trim(tmp_fname_trim, tmp_fname_noext); + // If it's a .sub, check if there is a .idx with the same name. If + // there is one, it's certainly a vobsub so we skip it. + if (strcasecmp(tmp_fname_ext, "sub") == 0) { + struct bstr idxname = BSTR(talloc_strdup(NULL, de->d_name)); + strcpy(idxname.start + idxname.len - sizeof("idx") + 1, "idx"); + char *idx = mp_path_join(idxname.start, path, idxname); + f = fopen(idx, "rt"); + talloc_free(idxname.start); + if (f) { + fclose(f); + continue; + } + } + // does it end with a subtitle extension? found = 0; #ifdef CONFIG_ICONV -- cgit v1.2.3