Skip to content

Commit

Permalink
command: add current-watch-later-dir property
Browse files Browse the repository at this point in the history
It will be used in the next commit.
  • Loading branch information
guidocella authored and kasper93 committed Jan 5, 2025
1 parent 0c3c4a3 commit b530b40
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions DOCS/interface-changes/current-watch-later-dir.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add `current-watch-later-dir` property
5 changes: 5 additions & 0 deletions DOCS/man/input.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3753,6 +3753,11 @@ Property list
The working directory of the mpv process. Can be useful for JSON IPC users,
because the command line player usually works with relative paths.

``current-watch-later-dir``
The directory in which watch later config files are stored. This returns
``--watch-later-dir``, or the default directory if ``--watch-later-dir`` has
not been modified, with tilde placeholders expanded.

``protocol-list``
List of protocol prefixes potentially recognized by the player. They are
returned without trailing ``://`` suffix (which is still always required).
Expand Down
8 changes: 8 additions & 0 deletions player/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -3528,6 +3528,13 @@ static int mp_property_cwd(void *ctx, struct m_property *prop,
return M_PROPERTY_NOT_IMPLEMENTED;
}

static int mp_property_current_watch_later_dir(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
return m_property_strdup_ro(action, arg, mp_get_playback_resume_dir(mpctx));
}

static int mp_property_protocols(void *ctx, struct m_property *prop,
int action, void *arg)
{
Expand Down Expand Up @@ -4388,6 +4395,7 @@ static const struct m_property mp_properties_base[] = {
{"ambient-light", mp_property_ambient_light},

{"working-directory", mp_property_cwd},
{"current-watch-later-dir", mp_property_current_watch_later_dir},

{"protocol-list", mp_property_protocols},
{"decoder-list", mp_property_decoders},
Expand Down
2 changes: 1 addition & 1 deletion player/configfiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ static bool copy_mtime(const char *f1, const char *f2)
return true;
}

static char *mp_get_playback_resume_dir(struct MPContext *mpctx)
char *mp_get_playback_resume_dir(struct MPContext *mpctx)
{
char *wl_dir = mpctx->opts->watch_later_dir;
if (wl_dir && wl_dir[0]) {
Expand Down
1 change: 1 addition & 0 deletions player/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ void audio_start_ao(struct MPContext *mpctx);
void mp_parse_cfgfiles(struct MPContext *mpctx);
void mp_load_auto_profiles(struct MPContext *mpctx);
bool mp_load_playback_resume(struct MPContext *mpctx, const char *file);
char *mp_get_playback_resume_dir(struct MPContext *mpctx);
void mp_write_watch_later_conf(struct MPContext *mpctx);
void mp_delete_watch_later_conf(struct MPContext *mpctx, const char *file);
struct playlist_entry *mp_check_playlist_resume(struct MPContext *mpctx,
Expand Down

0 comments on commit b530b40

Please sign in to comment.