summaryrefslogtreecommitdiffstats
path: root/player/external_files.c
diff options
context:
space:
mode:
Diffstat (limited to 'player/external_files.c')
-rw-r--r--player/external_files.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/player/external_files.c b/player/external_files.c
index 69610642d2..40fad916ef 100644
--- a/player/external_files.c
+++ b/player/external_files.c
@@ -42,6 +42,25 @@ static const char *const audio_exts[] = {"mp3", "aac", "mka", "dts", "flac",
"wv",
NULL};
+// Stolen from: vlc/-/blob/master/modules/meta_engine/folder.c#L40
+static const char *const cover_files[] = {
+ "Folder.jpg",
+ "Folder.png",
+ "AlbumArtSmall.jpg",
+ "AlbumArt.jpg",
+ "Album.jpg",
+ ".folder.png",
+ "cover.jpg",
+ "cover.png",
+ "cover.gif",
+ "front.jpg",
+ "front.png",
+ "front.gif",
+ "front.bmp",
+ "thumb.jpg",
+ NULL
+};
+
static bool test_ext_list(bstr ext, const char *const *list)
{
for (int n = 0; list[n]; n++) {
@@ -60,6 +79,15 @@ static int test_ext(bstr ext)
return -1;
}
+static int test_filename(bstr fname)
+{
+ for (int n = 0; cover_files[n]; n++) {
+ if (bstrcasecmp(bstr0(cover_files[n]), fname) == 0)
+ return STREAM_VIDEO;
+ }
+ return -1;
+}
+
bool mp_might_be_subtitle_file(const char *filename)
{
return test_ext(bstr_get_ext(bstr0(filename))) == STREAM_SUB;
@@ -159,6 +187,8 @@ static void append_dir_subtitles(struct mpv_global *global, struct MPOpts *opts,
// check what it is (most likely)
int type = test_ext(tmp_fname_ext);
+ if (type < 0)
+ type = test_filename(dename);
char **langs = NULL;
int fuzz = -1;
switch (type) {
@@ -170,6 +200,9 @@ static void append_dir_subtitles(struct mpv_global *global, struct MPOpts *opts,
langs = opts->stream_lang[type];
fuzz = opts->audiofile_auto;
break;
+ case STREAM_VIDEO:
+ fuzz = opts->coverart_auto;
+ break;
}
if (fuzz < 0 || (limit_type >= 0 && limit_type != type))
@@ -210,6 +243,10 @@ static void append_dir_subtitles(struct mpv_global *global, struct MPOpts *opts,
if (!limit_fuzziness && fuzz >= 2)
prio |= 1;
+ // cover art: just accept it
+ if (type == STREAM_VIDEO && fuzz >= 1)
+ prio |= 1;
+
mp_dbg(log, "Potential external file: \"%s\" Priority: %d\n",
de->d_name, prio);