Skip to content

Commit 995f6ca

Browse files
committed
loadfile: handle --watch-history-path like --watch-later-directory
In other words, leave the option value unset by default and use mp_find_user_file to get the desired state directory path. Default values are stored as is, so the old way of setting ~~/state directly didn't map well to the abstraction of trying to automatically parse M_OPT_FILE options since leaving the value as the default doesn't result in any parsing (or any operation on that specific option value).
1 parent 7b7f535 commit 995f6ca

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

DOCS/man/options.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,8 +1165,11 @@ Watch History
11651165
disabled by default.
11661166

11671167
``--watch-history-path=<path>``
1168-
The path in which to store the watch history. Default:
1169-
``~~state/watch_history.jsonl`` (see `FILES`_).
1168+
The path in which to store the watch history.
1169+
1170+
If this option is unset, the file will be stored as ``watch_history.jsonl``
1171+
in the local state directory. This is usually ``~/.local/state/mpv/`` (see
1172+
`FILES`_).
11701173

11711174
This file contains one JSON object per line. Its ``time`` field is the UNIX
11721175
timestamp when the file was opened, its ``path`` field is the normalized

options/options.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,6 @@ static const struct MPOpts mp_default_opts = {
10131013
.sync_max_factor = 5,
10141014
.load_config = true,
10151015
.position_resume = true,
1016-
.watch_history_path = "~~state/watch_history.jsonl",
10171016
.autoload_files = true,
10181017
.demuxer_thread = true,
10191018
.demux_termination_timeout = 0.1,

player/loadfile.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,8 @@ static void append_to_watch_history(struct MPContext *mpctx)
15461546

15471547
void *ctx = talloc_new(NULL);
15481548
char *history_path = mpctx->opts->watch_history_path;
1549+
if (!history_path || !history_path[0])
1550+
history_path = mp_find_user_file(ctx, mpctx->log, "state", "watch_history.jsonl");
15491551
char *history_path_dir = bstrto0(ctx, mp_dirname(history_path));
15501552
mp_mkdirp(history_path_dir);
15511553

0 commit comments

Comments
 (0)