mirror of
https://github.com/mpv-player/mpv
synced 2025-02-19 14:26:57 +00:00
external_files: allow specifying --cover-art-whitelist filenames
Fixes https://github.com/mpv-player/mpv/discussions/14520.
This commit is contained in:
parent
e509ec0aaf
commit
d384a6b793
@ -0,0 +1 @@
|
||||
turn `--cover-art-whitelist` into a list option
|
@ -7478,13 +7478,14 @@ Miscellaneous
|
||||
|
||||
This is a string list option. See `List Options`_ for details.
|
||||
|
||||
``--cover-art-whitelist=<no|yes>``
|
||||
Whether to load files with a filename among "AlbumArt", "Album", "cover",
|
||||
"front", "AlbumArtSmall", "Folder", ".folder", "thumb", and an extension in
|
||||
``--cover-art-auto-exts``, as cover art. This has no effect if
|
||||
``cover-art-auto`` is ``no``.
|
||||
``--cover-art-whitelist=filename1,filename2,...``
|
||||
Filenames to load as cover art, sorted by descending priority. They are
|
||||
combined with the extensions in ``--cover-art-auto-exts``. This has no
|
||||
effect if ``cover-art-auto`` is ``no``.
|
||||
|
||||
Default: ``yes``.
|
||||
Default: ``AlbumArt,Album,cover,front,AlbumArtSmall,Folder,.folder,thumb``
|
||||
|
||||
This is a string list option. See `List Options`_ for details.
|
||||
|
||||
``--autoload-files=<yes|no>``
|
||||
Automatically load/select external files (default: yes).
|
||||
|
@ -709,7 +709,7 @@ static const m_option_t mp_opts[] = {
|
||||
{"cover-art-auto", OPT_CHOICE(coverart_auto,
|
||||
{"no", -1}, {"exact", 0}, {"fuzzy", 1}, {"all", 2})},
|
||||
{"cover-art-auto-exts", OPT_STRINGLIST(coverart_auto_exts)},
|
||||
{"cover-art-whitelist", OPT_BOOL(coverart_whitelist)},
|
||||
{"cover-art-whitelist", OPT_STRINGLIST(coverart_whitelist)},
|
||||
|
||||
{"", OPT_SUBSTRUCT(subs_rend, mp_subtitle_sub_opts)},
|
||||
{"", OPT_SUBSTRUCT(subs_shared, mp_subtitle_shared_sub_opts)},
|
||||
@ -1030,7 +1030,6 @@ static const struct MPOpts mp_default_opts = {
|
||||
.playback_speed = 1.,
|
||||
.pitch_correction = true,
|
||||
.audiofile_auto = -1,
|
||||
.coverart_whitelist = true,
|
||||
.osd_bar_visible = true,
|
||||
.screenshot_template = "mpv-shot%n",
|
||||
.play_dir = 1,
|
||||
@ -1087,6 +1086,20 @@ static const struct MPOpts mp_default_opts = {
|
||||
NULL
|
||||
},
|
||||
|
||||
// Stolen from: vlc/-/blob/master/modules/meta_engine/folder.c#L40
|
||||
// sorted by priority (descending)
|
||||
.coverart_whitelist = (char *[]){
|
||||
"AlbumArt",
|
||||
"Album",
|
||||
"cover",
|
||||
"front",
|
||||
"AlbumArtSmall",
|
||||
"Folder",
|
||||
".folder",
|
||||
"thumb",
|
||||
NULL
|
||||
},
|
||||
|
||||
.audio_output_channels = {
|
||||
.set = 1,
|
||||
.auto_safe = 1,
|
||||
|
@ -334,7 +334,7 @@ typedef struct MPOpts {
|
||||
char **audiofile_auto_exts;
|
||||
int coverart_auto;
|
||||
char **coverart_auto_exts;
|
||||
bool coverart_whitelist;
|
||||
char **coverart_whitelist;
|
||||
bool osd_bar_visible;
|
||||
|
||||
int w32_priority;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user