Skip to content

Commit

Permalink
options: add --playlist-exts
Browse files Browse the repository at this point in the history
And add playlist to --directory-filter-types' default.

Fixes
#15096 (comment),
fixes #15508
  • Loading branch information
guidocella committed Dec 22, 2024
1 parent 438b7e5 commit a906d18
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
2 changes: 2 additions & 0 deletions DOCS/interface-changes/exts.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
add `--archive-exts`
add `archive` to `--directory-filter-types`' default
add `--playlist-exts`
add `playlist` to `--directory-filter-types`' default
9 changes: 8 additions & 1 deletion DOCS/man/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4215,7 +4215,7 @@ Demuxer
``--directory-filter-types=<video,audio,image>``
Media file types to filter when opening directory. If the list is empty,
all files are added to the playlist. (Default:
``video,audio,image,archive``)
``video,audio,image,archive,playlist``)

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

Expand Down Expand Up @@ -7739,6 +7739,13 @@ Miscellaneous
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
21 changes: 14 additions & 7 deletions demux/demux_playlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ enum dir_mode {
};

enum autocreate_mode {
AUTO_NONE = 0,
AUTO_VIDEO = 1 << 0,
AUTO_AUDIO = 1 << 1,
AUTO_IMAGE = 1 << 2,
AUTO_ARCHIVE = 1 << 3,
AUTO_ANY = 1 << 4,
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 @@ -73,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", "archive", NULL
"video", "audio", "image", "archive", "playlist", NULL
},
},
};
Expand Down Expand Up @@ -440,6 +441,8 @@ static bool test_path(struct pl_parser *p, char *path, int autocreate)
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 @@ -525,6 +528,8 @@ static enum autocreate_mode get_directory_filter(struct pl_parser *p)
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 @@ -549,6 +554,8 @@ static int parse_dir(struct pl_parser *p)
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
4 changes: 4 additions & 0 deletions options/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ static const m_option_t mp_opts[] = {
{"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 @@ -1041,6 +1042,9 @@ static const struct MPOpts mp_default_opts = {
.archive_exts = (char *[]){
"zip", "rar", "7z", "cbz", "cbr", NULL
},
.playlist_exts = (char *[]){
"m3u", "m3u8", "pls", "edl", NULL
},

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

int w32_priority;
Expand Down

0 comments on commit a906d18

Please sign in to comment.