external_files: allow specifying --cover-art-whitelist filenames

Fixes https://github.com/mpv-player/mpv/discussions/14520.
This commit is contained in:
Guido Cella
2024-07-13 07:57:06 +02:00
committed by Dudemanguy
parent e509ec0aaf
commit d384a6b793
5 changed files with 30 additions and 27 deletions

View File

@@ -30,20 +30,6 @@
#include "options/path.h"
#include "external_files.h"
// Stolen from: vlc/-/blob/master/modules/meta_engine/folder.c#L40
// sorted by priority (descending)
static const char *const cover_files[] = {
"AlbumArt",
"Album",
"cover",
"front",
"AlbumArtSmall",
"Folder",
".folder",
"thumb",
NULL
};
// Needed for mp_might_be_subtitle_file
char **sub_exts;
@@ -70,11 +56,13 @@ static int test_ext(MPOpts *opts, bstr ext)
return -1;
}
static int test_cover_filename(bstr fname)
static int test_cover_filename(bstr fname, char **cover_files)
{
for (int n = 0; cover_files[n]; n++) {
if (bstrcasecmp(bstr0(cover_files[n]), fname) == 0) {
return MP_ARRAY_SIZE(cover_files) - n;
size_t size = n;
while (cover_files[++size]);
return size - n;
}
}
return 0;
@@ -198,8 +186,8 @@ static void append_dir_subtitles(struct mpv_global *global, struct MPOpts *opts,
if (bstr_find(tmp_fname_trim, f_fname_trim) >= 0 && fuzz >= 1)
prio |= 2; // contains the movie name
if (type == STREAM_VIDEO && opts->coverart_whitelist && prio == 0)
prio = test_cover_filename(tmp_fname_trim);
if (type == STREAM_VIDEO && prio == 0)
prio = test_cover_filename(tmp_fname_trim, opts->coverart_whitelist);
// doesn't contain the movie name
// don't try in the mplayer subtitle directory