1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-29 10:32:15 +00:00

player: change cover-art-auto behavior

This makes cover-art-auto behave more like sub-auto and audio-file-auto:

- load cover art with a language, e.g. if playing foo.mp3, foo.en.jpg
will be loaded with lang=en
- load cover art containing the media filename with fuzzy and all, e.g.
'foo (large).jpg'
- make all/2 load all images in the directory, and make fuzzy/1 the
default

These are all uncommon use cases, but synchronizing the behavior of the
external file options simplifies the code.
This commit is contained in:
Guido Cella 2021-06-21 18:27:44 +02:00 committed by Dudemanguy
parent 0427fe97e1
commit cb56c2f888
3 changed files with 8 additions and 12 deletions

View File

@ -6729,9 +6729,9 @@ Miscellaneous
:no: Don't automatically load cover art.
:exact: Load the media filename with an image file extension.
:fuzzy: Load cover art with a filename included in an internal whitelist,
such as ``cover.jpg``.
:all: Union of exact and fuzzy (default).
:fuzzy: Load all cover art containing the media filename and filenames
in an internal whitelist, such as ``cover.jpg`` (default).
:all: Load all images in the current directory.
See ``--cover-art-files`` for details about what constitutes cover art.

View File

@ -1018,7 +1018,7 @@ static const struct MPOpts mp_default_opts = {
.pitch_correction = 1,
.sub_auto = 0,
.audiofile_auto = -1,
.coverart_auto = 2,
.coverart_auto = 1,
.osd_bar_visible = 1,
.screenshot_template = "mpv-shot%n",
.play_dir = 1,

View File

@ -220,13 +220,10 @@ static void append_dir_subtitles(struct mpv_global *global, struct MPOpts *opts,
// higher prio -> auto-selection may prefer it (0 = not loaded)
int prio = 0;
if (bstrcmp(tmp_fname_trim, f_fname_trim) == 0 &&
(type != STREAM_VIDEO || fuzz != 1))
if (bstrcmp(tmp_fname_trim, f_fname_trim) == 0)
prio |= 32; // exact movie name match
bstr lang = {0};
if (type == STREAM_VIDEO)
goto cover_art;
if (bstr_startswith(tmp_fname_trim, f_fname_trim)) {
int start = 0;
lang = guess_lang_from_filename(tmp_fname_trim, &start);
@ -249,15 +246,14 @@ 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 && fuzz >= 1 && prio == 0)
prio = test_cover_filename(dename);
// doesn't contain the movie name
// don't try in the mplayer subtitle directory
if (!limit_fuzziness && fuzz >= 2)
prio |= 1;
cover_art:
if (type == STREAM_VIDEO && fuzz >= 1 && prio == 0)
prio = test_cover_filename(dename);
mp_dbg(log, "Potential external file: \"%s\" Priority: %d\n",
de->d_name, prio);