History

demux_playlist: use --directory-filter-types for --autocreate-playlist

Kacper Michajłow committed 2 years ago

Commit 4e50da31 parent ff1f8ba3 files · +22 −20Browse files

Unified · Split

3 files
  1. DOCS/man/options.rst +2 −3
  2. demux/demux.c +1 −1
  3. demux/demux_playlist.c +19 −16
DOCS/man/options.rst+2−3
@@ -4147,14 +4147,13 @@ Demuxer · 4146 unmodified lines
41474147
41484148 This is a string list option. See `List Options`_ for details.
41494149
4150−``--autocreate-playlist=<no|any|filter|same>``
4150+``--autocreate-playlist=<no|filter|same>``
41514151 When opening a local file, act as if the parent directory is opened and
41524152 create a playlist automatically.
41534153
41544154 :no: Load a single file (default).
4155− :any: Create a playlist from the parent directory with any file type.
41564155 :filter: Create a playlist from the parent directory with files matching
4157− extensions from any list ``*-exts``.
4156+ ``--directory-filter-types``.
41584157 :same: Create a playlist from the parent directory with files matching the
41594158 same category as the currently loaded file. One of the
41604159 ``*-exts`` is selected based on the input file
demux/demux.c+1−1
@@ -120,7 +120,7 @@ const struct m_sub_options demux_conf = { · 119 unmodified lines
120120 M_RANGE(0, DBL_MAX)},
121121 {"metadata-codepage", OPT_STRING(meta_cp)},
122122 {"autocreate-playlist", OPT_CHOICE(autocreate_playlist,
123− {"no", 0}, {"any", 1}, {"filter", 2}, {"same", 3})},
123+ {"no", 0}, {"filter", 1}, {"same", 2})},
124124 {0}
125125 },
126126 .size = sizeof(struct demux_opts),
demux/demux_playlist.c+19−16
@@ -495,22 +495,33 @@ static bool scan_dir(struct pl_parser *p, char *path, · 494 unmodified lines
495495 return true;
496496 }
497497
498+static enum autocreate_mode get_directory_filter(struct pl_parser *p)
499+{
500+ enum autocreate_mode autocreate = AUTO_NONE;
501+ if (!p->opts->directory_filter || !p->opts->directory_filter[0])
502+ autocreate = AUTO_ANY;
503+ if (str_in_list(bstr0("video"), p->opts->directory_filter))
504+ autocreate |= AUTO_VIDEO;
505+ if (str_in_list(bstr0("audio"), p->opts->directory_filter))
506+ autocreate |= AUTO_AUDIO;
507+ if (str_in_list(bstr0("image"), p->opts->directory_filter))
508+ autocreate |= AUTO_IMAGE;
509+ return autocreate;
510+}
511+
498512 static int parse_dir(struct pl_parser *p)
499513 {
500514 int ret = -1;
501515 struct stream *stream = p->real_stream;
502− int autocreate = AUTO_NONE;
516+ enum autocreate_mode autocreate = AUTO_NONE;
503517 p->pl->playlist_dir = NULL;
504518 if (p->autocreate_playlist && p->real_stream->is_local_file && !p->real_stream->is_directory) {
505519 bstr ext = bstr_get_ext(bstr0(p->real_stream->url));
506520 switch (p->autocreate_playlist) {
507− case 1: // any
508− autocreate = AUTO_ANY;
509− break;
510− case 2: // filter
511− autocreate = AUTO_VIDEO | AUTO_AUDIO | AUTO_IMAGE;
521+ case 1: // filter
522+ autocreate = get_directory_filter(p);
512523 break;
513− case 3: // same
524+ case 2: // same
514525 if (str_in_list(ext, p->mp_opts->video_exts)) {
515526 autocreate = AUTO_VIDEO;
516527 } else if (str_in_list(ext, p->mp_opts->audio_exts)) {
@@ -530,15 +541,7 @@ static int parse_dir(struct pl_parser *p) · 13 unmodified lines
530541 p->pl->playlist_dir = bstrdup0(p->pl, dir);
531542 }
532543 } else {
533− autocreate = AUTO_NONE;
534− if (!p->opts->directory_filter || !p->opts->directory_filter[0])
535− autocreate = AUTO_ANY;
536− if (str_in_list(bstr0("video"), p->opts->directory_filter))
537− autocreate |= AUTO_VIDEO;
538− if (str_in_list(bstr0("audio"), p->opts->directory_filter))
539− autocreate |= AUTO_AUDIO;
540− if (str_in_list(bstr0("image"), p->opts->directory_filter))
541− autocreate |= AUTO_IMAGE;
544+ autocreate = get_directory_filter(p);
542545 }
543546 if (!stream->is_directory)
544547 goto done;

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