History

options: add --{video,audio,image}-exts

Kacper Michajłow committed 2 years ago

Commit 44a3a321 parent 4f1e9e36 files · +50 −85Browse files

Unified · Split

6 files
  1. DOCS/interface-changes/autocreate-playlist.txt +3 −3
  2. DOCS/man/options.rst +18 −19
  3. demux/demux_playlist.c +9 −28
  4. options/options.c +15 −31
  5. options/options.h +3 −2
  6. player/external_files.c +2 −2
DOCS/interface-changes/autocreate-playlist.txt+3−3
@@ -1,4 +1,4 @@
11 add `--autocreate-playlist`
2−add `--directory-video-exts`
3−add `--directory-audio-exts`
4−add `--directory-image-exts`
2+add `--video-exts`
3+add `--audio-exts`
4+add `--image-exts`
DOCS/man/options.rst+18−19
@@ -2277,10 +2277,12 @@ Audio · 2276 unmodified lines
22772277 :all: Load all audio files in the current and ``--audio-file-paths``
22782278 directories.
22792279
2280−``--audio-file-auto-exts=ext1,ext2,...``
2281− Audio file extentions to try and match when using ``audio-file-auto``.
2280+``--audio-exts=ext1,ext2,...``
2281+ Audio file extentions to try to match when using ``--audio-file-auto``,
2282+ ``--autocreate-playlist`` or ``--directory-filter-types``.
22822283
22832284 This is a string list option. See `List Options`_ for details.
2285+ Use ``--help=audio-exts`` to see default extensions.
22842286
22852287 ``--audio-file-paths=<path1:path2:...>``
22862288 Equivalent to ``--sub-file-paths`` option, but for auto-loaded audio files.
@@ -4152,26 +4154,14 @@ Demuxer · 1865 unmodified lines
41524154 :no: Load a single file (default).
41534155 :any: Create a playlist from the parent directory with any file type.
41544156 :filter: Create a playlist from the parent directory with files matching
4155− extensions from any list ``directory-*-exts``.
4157+ extensions from any list ``*-exts``.
41564158 :same: Create a playlist from the parent directory with files matching the
41574159 same category as the currently loaded file. One of the
4158− ``directory-*-exts`` is selected based on the input file
4160+ ``*-exts`` is selected based on the input file
41594161 and only files with matching extensions are added to the playlist.
41604162 If the input file itself is not matched to any extension list,
41614163 the playlist is not autogenerated.
41624164
4163−``--directory-video-exts=<ext1,ext2,...>``
4164− Video file extension list that is used to match files when using
4165− ``--autocreate-playlist=<exts|same>``.
4166−
4167−``--directory-audio-exts=<ext1,ext2,...>``
4168− Audio file extension list that is used to match files when using
4169− ``--autocreate-playlist=<exts|same>``.
4170−
4171−``--directory-image-exts=<ext1,ext2,...>``
4172− Image file extension list that is used to match files when using
4173− ``--autocreate-playlist=<exts|same>``.
4174−
41754165 Input
41764166 -----
41774167
@@ -7540,20 +7530,29 @@ Miscellaneous · 3362 unmodified lines
75407530 See ``--audio-display`` how to control display of cover art (this can be
75417531 used to disable cover art that is part of the file).
75427532
7543−``--cover-art-auto-exts=ext1,ext2,...``
7544− Cover art extentions to try and match when using ``cover-art-auto``.
7533+``--image-exts=ext1,ext2,...``
7534+ Image file extentions to try to match when using ``--cover-art-auto``,
7535+ ``--autocreate-playlist`` or ``--directory-filter-types``.
75457536
75467537 This is a string list option. See `List Options`_ for details.
7538+ Use ``--help=image-exts`` to see default extensions.
75477539
75487540 ``--cover-art-whitelist=filename1,filename2,...``
75497541 Filenames to load as cover art, sorted by descending priority. They are
7550− combined with the extensions in ``--cover-art-auto-exts``. This has no
7542+ combined with the extensions in ``--image-exts``. This has no
75517543 effect if ``cover-art-auto`` is ``no``.
75527544
75537545 Default: ``AlbumArt,Album,cover,front,AlbumArtSmall,Folder,.folder,thumb``
75547546
75557547 This is a string list option. See `List Options`_ for details.
75567548
7549+``--video-exts=ext1,ext2,...``
7550+ Video file extentions to try to match when using ``--autocreate-playlist`` or
7551+ ``--directory-filter-types``.
7552+
7553+ This is a string list option. See `List Options`_ for details.
7554+ Use ``--help=video-exts`` to see default extensions.
7555+
75577556 ``--autoload-files=<yes|no>``
75587557 Automatically load/select external files (default: yes).
75597558
demux/demux_playlist.c+9−28
@@ -54,9 +54,6 @@ enum autocreate_mode { · 53 unmodified lines
5454 struct demux_playlist_opts {
5555 int dir_mode;
5656 char **directory_filter;
57− char **directory_vid_exts;
58− char **directory_aud_exts;
59− char **directory_img_exts;
6057 };
6158
6259 struct m_sub_options demux_playlist_conf = {
@@ -68,12 +65,6 @@ struct m_sub_options demux_playlist_conf = { · 5 unmodified lines
6865 {"ignore", DIR_IGNORE})},
6966 {"directory-filter-types",
7067 OPT_STRINGLIST(directory_filter)},
71− {"directory-video-exts",
72− OPT_STRINGLIST(directory_vid_exts)},
73− {"directory-audio-exts",
74− OPT_STRINGLIST(directory_aud_exts)},
75− {"directory-image-exts",
76− OPT_STRINGLIST(directory_img_exts)},
7768 {0}
7869 },
7970 .size = sizeof(struct demux_playlist_opts),
@@ -82,18 +73,6 @@ struct m_sub_options demux_playlist_conf = { · 2 unmodified lines
8273 .directory_filter = (char *[]){
8374 NULL
8475 },
85− .directory_vid_exts = (char *[]){
86− "3g2", "3gp", "avi", "flv", "m2ts", "m4v", "mj2", "mkv", "mov",
87− "mp4", "mpeg", "mpg", "ogv", "rmvb", "webm", "wmv", "y4m", NULL
88− },
89− .directory_aud_exts = (char *[]){
90− "aiff", "ape", "au", "flac", "m4a", "mka", "mp3", "oga", "ogg",
91− "ogm", "opus", "wav", "wma", NULL
92− },
93− .directory_img_exts = (char *[]){
94− "avif", "bmp", "gif", "j2k", "jp2", "jpeg", "jpg", "jxl", "png",
95− "svg", "tga", "tif", "tiff", "webp", NULL
96− },
9776 },
9877 };
9978
@@ -126,6 +105,7 @@ struct pl_parser { · 26 unmodified lines
126105 char *format;
127106 char *codepage;
128107 struct demux_playlist_opts *opts;
108+ struct MPOpts *mp_opts;
129109 };
130110
131111
@@ -447,11 +427,11 @@ static bool test_path(struct pl_parser *p, char *path, int autocreate) · 315 unmodified lines
447427 return true;
448428
449429 bstr ext = bstr_get_ext(bstr0(path));
450− if (autocreate & AUTO_VIDEO && has_str(ext, p->opts->directory_vid_exts))
430+ if (autocreate & AUTO_VIDEO && has_str(ext, p->mp_opts->video_exts))
451431 return true;
452− if (autocreate & AUTO_AUDIO && has_str(ext, p->opts->directory_aud_exts))
432+ if (autocreate & AUTO_AUDIO && has_str(ext, p->mp_opts->audio_exts))
453433 return true;
454− if (autocreate & AUTO_IMAGE && has_str(ext, p->opts->directory_img_exts))
434+ if (autocreate & AUTO_IMAGE && has_str(ext, p->mp_opts->image_exts))
455435 return true;
456436
457437 return false;
@@ -541,11 +521,11 @@ static int parse_dir(struct pl_parser *p) · 83 unmodified lines
541521 autocreate = AUTO_VIDEO | AUTO_AUDIO | AUTO_IMAGE;
542522 break;
543523 case 3: // same
544− if (has_str(ext, p->opts->directory_vid_exts)) {
524+ if (has_str(ext, p->mp_opts->video_exts)) {
545525 autocreate = AUTO_VIDEO;
546− } else if (has_str(ext, p->opts->directory_aud_exts)) {
526+ } else if (has_str(ext, p->mp_opts->audio_exts)) {
547527 autocreate = AUTO_AUDIO;
548− } else if (has_str(ext, p->opts->directory_img_exts)) {
528+ } else if (has_str(ext, p->mp_opts->image_exts)) {
549529 autocreate = AUTO_IMAGE;
550530 }
551531 break;
@@ -561,7 +541,7 @@ static int parse_dir(struct pl_parser *p) · 9 unmodified lines
561541 }
562542 } else {
563543 autocreate = AUTO_NONE;
564− if (!p->opts->directory_filter[0])
544+ if (!p->opts->directory_filter || !p->opts->directory_filter[0])
565545 autocreate = AUTO_ANY;
566546 if (has_str(bstr0("video"), p->opts->directory_filter))
567547 autocreate |= AUTO_VIDEO;
@@ -675,6 +655,7 @@ static int open_file(struct demuxer *demuxer, enum demux_check check) · 107 unmodified lines
675655 p->check_level = check;
676656 p->probing = true;
677657 p->autocreate_playlist = demuxer->params->allow_playlist_create ? opts->autocreate_playlist : 0;
658+ p->mp_opts = mp_get_config_group(demuxer, demuxer->global, &mp_opt_root);
678659 p->opts = mp_get_config_group(demuxer, demuxer->global, &demux_playlist_conf);
679660
680661 const struct pl_format *fmts = playlist_formats;
options/options.c+15−31
@@ -720,11 +720,14 @@ static const m_option_t mp_opts[] = { · 719 unmodified lines
720720 {"sub-auto-exts", OPT_STRINGLIST(sub_auto_exts), .flags = UPDATE_SUB_EXTS},
721721 {"audio-file-auto", OPT_CHOICE(audiofile_auto,
722722 {"no", -1}, {"exact", 0}, {"fuzzy", 1}, {"all", 2})},
723− {"audio-file-auto-exts", OPT_STRINGLIST(audiofile_auto_exts)},
723+ {"audio-exts", OPT_STRINGLIST(audio_exts)},
724+ {"audio-file-auto-exts", OPT_ALIAS("audio-exts")},
724725 {"cover-art-auto", OPT_CHOICE(coverart_auto,
725726 {"no", -1}, {"exact", 0}, {"fuzzy", 1}, {"all", 2})},
726− {"cover-art-auto-exts", OPT_STRINGLIST(coverart_auto_exts)},
727+ {"image-exts", OPT_STRINGLIST(image_exts)},
728+ {"cover-art-auto-exts", OPT_ALIAS("image-exts")},
727729 {"cover-art-whitelist", OPT_STRINGLIST(coverart_whitelist)},
730+ {"video-exts", OPT_STRINGLIST(video_exts)},
728731
729732 {"", OPT_SUBSTRUCT(subs_rend, mp_subtitle_sub_opts)},
730733 {"", OPT_SUBSTRUCT(subs_shared, mp_subtitle_shared_sub_opts)},
@@ -1044,36 +1047,17 @@ static const struct MPOpts mp_default_opts = { · 313 unmodified lines
10441047 .screenshot_template = "mpv-shot%n",
10451048 .play_dir = 1,
10461049 .media_controls = 1,
1047−
1048− .audiofile_auto_exts = (char *[]){
1049− "aac",
1050− "ac3",
1051− "dts",
1052− "eac3",
1053− "flac",
1054− "m4a",
1055− "mka",
1056− "mp3",
1057− "ogg",
1058− "opus",
1059− "thd",
1060− "wav",
1061− "wv",
1062− NULL
1050+ .video_exts = (char *[]){
1051+ "3g2", "3gp", "avi", "flv", "m2ts", "m4v", "mj2", "mkv", "mov", "mp4",
1052+ "mpeg", "mpg", "ogv", "rmvb", "ts", "webm", "wmv", "y4m", NULL
10631053 },
1064−
1065− .coverart_auto_exts = (char *[]){
1066− "avif",
1067− "bmp",
1068− "gif",
1069− "jpeg",
1070− "jpg",
1071− "jxl",
1072− "png",
1073− "tif",
1074− "tiff",
1075− "webp",
1076− NULL
1054+ .audio_exts = (char *[]){
1055+ "aac", "ac3", "aiff", "ape", "au", "dts", "eac3", "flac", "m4a", "mka",
1056+ "mp3", "oga", "ogg", "ogm", "opus", "thd", "wav", "wav", "wma", "wv", NULL
1057+ },
1058+ .image_exts = (char *[]){
1059+ "avif", "bmp", "gif", "j2k", "jp2", "jpeg", "jpg", "jxl", "png",
1060+ "svg", "tga", "tif", "tiff", "webp", NULL
10771061 },
10781062
10791063 .sub_auto_exts = (char *[]){
options/options.h+3−2
@@ -338,10 +338,11 @@ typedef struct MPOpts { · 337 unmodified lines
338338 int sub_auto;
339339 char **sub_auto_exts;
340340 int audiofile_auto;
341− char **audiofile_auto_exts;
341+ char **audio_exts;
342342 int coverart_auto;
343− char **coverart_auto_exts;
343+ char **image_exts;
344344 char **coverart_whitelist;
345+ char **video_exts;
345346 bool osd_bar_visible;
346347
347348 int w32_priority;
player/external_files.c+2−2
@@ -49,9 +49,9 @@ static int test_ext(MPOpts *opts, bstr ext) · 48 unmodified lines
4949 {
5050 if (test_ext_list(ext, opts->sub_auto_exts))
5151 return STREAM_SUB;
52− if (test_ext_list(ext, opts->audiofile_auto_exts))
52+ if (test_ext_list(ext, opts->audio_exts))
5353 return STREAM_AUDIO;
54− if (test_ext_list(ext, opts->coverart_auto_exts))
54+ if (test_ext_list(ext, opts->image_exts))
5555 return STREAM_VIDEO;
5656 return -1;
5757 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t