Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

options: add --archive-exts and --playlist-exts #15551

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions DOCS/interface-changes/exts.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
add `--archive-exts`
add `archive` to `--directory-filter-types`' default
add `--playlist-exts`
add `playlist` to `--directory-filter-types`' default
19 changes: 17 additions & 2 deletions DOCS/man/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4212,9 +4212,10 @@ Demuxer
all. The default is ``auto``, which behaves like ``recursive`` with
``--shuffle``, and like ``lazy`` otherwise.

``--directory-filter-types=<video,audio,image>``
``--directory-filter-types=<video,audio,image,archive,playlist>``
Media file types to filter when opening directory. If the list is empty,
all files are added to the playlist. (Default: ``video,audio,image``)
all files are added to the playlist. (Default:
``video,audio,image,archive,playlist``)

This is a string list option. See `List Options`_ for details.

Expand Down Expand Up @@ -7731,6 +7732,20 @@ Miscellaneous
This is a string list option. See `List Options`_ for details.
Use ``--help=video-exts`` to see default extensions.

``--archive-exts=ext1,ext2,...``
Archive file extentions to try to match when using ``--autocreate-playlist``
or ``--directory-filter-types``.

This is a string list option. See `List Options`_ for details. Use
``--help=archive-exts`` to see the default extensions.

``--playlist-exts=ext1,ext2,...``
Playlist file extentions to try to match when using
``--autocreate-playlist`` or ``--directory-filter-types``.

This is a string list option. See `List Options`_ for details. Use
``--help=playlist-exts`` to see the default extensions.

``--autoload-files=<yes|no>``
Automatically load/select external files (default: yes).

Expand Down
26 changes: 20 additions & 6 deletions demux/demux_playlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ enum dir_mode {
};

enum autocreate_mode {
AUTO_NONE = 0,
AUTO_VIDEO = 1 << 0,
AUTO_AUDIO = 1 << 1,
AUTO_IMAGE = 1 << 2,
AUTO_ANY = 1 << 3,
AUTO_NONE = 0,
AUTO_VIDEO = 1 << 0,
AUTO_AUDIO = 1 << 1,
AUTO_IMAGE = 1 << 2,
AUTO_ARCHIVE = 1 << 3,
AUTO_PLAYLIST = 1 << 4,
AUTO_ANY = 1 << 5,
};

#define OPT_BASE_STRUCT struct demux_playlist_opts
Expand All @@ -72,7 +74,7 @@ struct m_sub_options demux_playlist_conf = {
.defaults = &(const struct demux_playlist_opts){
.dir_mode = DIR_AUTO,
.directory_filter = (char *[]){
"video", "audio", "image", NULL
"video", "audio", "image", "archive", "playlist", NULL
},
},
};
Expand Down Expand Up @@ -437,6 +439,10 @@ static bool test_path(struct pl_parser *p, char *path, int autocreate)
return true;
if (autocreate & AUTO_IMAGE && str_in_list(ext, p->mp_opts->image_exts))
return true;
if (autocreate & AUTO_ARCHIVE && str_in_list(ext, p->mp_opts->archive_exts))
return true;
if (autocreate & AUTO_PLAYLIST && str_in_list(ext, p->mp_opts->playlist_exts))
return true;

return false;
}
Expand Down Expand Up @@ -520,6 +526,10 @@ static enum autocreate_mode get_directory_filter(struct pl_parser *p)
autocreate |= AUTO_AUDIO;
if (str_in_list(bstr0("image"), p->opts->directory_filter))
autocreate |= AUTO_IMAGE;
if (str_in_list(bstr0("archive"), p->opts->directory_filter))
autocreate |= AUTO_ARCHIVE;
if (str_in_list(bstr0("playlist"), p->opts->directory_filter))
autocreate |= AUTO_PLAYLIST;
return autocreate;
}

Expand All @@ -542,6 +552,10 @@ static int parse_dir(struct pl_parser *p)
autocreate = AUTO_AUDIO;
} else if (str_in_list(ext, p->mp_opts->image_exts)) {
autocreate = AUTO_IMAGE;
} else if (str_in_list(ext, p->mp_opts->archive_exts)) {
autocreate = AUTO_ARCHIVE;
} else if (str_in_list(ext, p->mp_opts->playlist_exts)) {
autocreate = AUTO_PLAYLIST;
}
break;
}
Expand Down
8 changes: 8 additions & 0 deletions options/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,8 @@ static const m_option_t mp_opts[] = {
{"cover-art-auto-exts", OPT_ALIAS("image-exts")},
{"cover-art-whitelist", OPT_STRINGLIST(coverart_whitelist)},
{"video-exts", OPT_STRINGLIST(video_exts)},
{"archive-exts", OPT_STRINGLIST(archive_exts)},
{"playlist-exts", OPT_STRINGLIST(playlist_exts)},

{"", OPT_SUBSTRUCT(subs_rend, mp_subtitle_sub_opts)},
{"", OPT_SUBSTRUCT(subs_shared, mp_subtitle_shared_sub_opts)},
Expand Down Expand Up @@ -1037,6 +1039,12 @@ static const struct MPOpts mp_default_opts = {
"avif", "bmp", "gif", "heic", "heif", "j2k", "jp2", "jpeg", "jpg",
"jxl", "png", "qoi", "svg", "tga", "tif", "tiff", "webp", NULL
},
.archive_exts = (char *[]){
"zip", "rar", "7z", "cbz", "cbr", NULL
},
.playlist_exts = (char *[]){
"m3u", "m3u8", "pls", "edl", NULL
},

.sub_auto_exts = (char *[]){
"ass",
Expand Down
2 changes: 2 additions & 0 deletions options/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ typedef struct MPOpts {
char **image_exts;
char **coverart_whitelist;
char **video_exts;
char **archive_exts;
char **playlist_exts;
bool osd_bar_visible;

int w32_priority;
Expand Down
Loading