diff --git a/DOCS/interface-changes/current-watch-later-dir.txt b/DOCS/interface-changes/current-watch-later-dir.txt new file mode 100644 index 0000000000000..3fed357341f1f --- /dev/null +++ b/DOCS/interface-changes/current-watch-later-dir.txt @@ -0,0 +1 @@ +add `current-watch-later-dir` property diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index c9d1c50c3a953..267c4585d0081 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -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). diff --git a/player/command.c b/player/command.c index eeda2f8c81ef4..cc9c84e2bcef3 100644 --- a/player/command.c +++ b/player/command.c @@ -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) { @@ -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}, diff --git a/player/configfiles.c b/player/configfiles.c index 359a6312f78c1..ceb405c0cdd40 100644 --- a/player/configfiles.c +++ b/player/configfiles.c @@ -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]) { diff --git a/player/core.h b/player/core.h index 23c167128de09..9ce0f1daca930 100644 --- a/player/core.h +++ b/player/core.h @@ -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,