player: Optionally validate st_mtime when restoring playback state

I often watch sporting events. On many occasions I get files with the
same filename for each session. For example, for F1 I might have the
following directory structure:

    F1/
        FP1.mkv
        FP2.mkv
        FP3.mkv
        Qualification.mkv
        Race.mkv

Since usually one simply watches one race after the other, I usually
just rsync the new event's files over the old ones, so, for example,
Race.mkv will be replaced from the file for the last event with the file
from the new event.

One problem with this is that I like to use --resume-playback for other
kinds of media, so I have it on by default. That works great for, say, a
movie, but doesn't work so well with this scheme, because you can
trivially forget to pass --no-resume-playback on the command line and
end up 2 hours in, watching spoilers as the race results scroll down the
screen :-)

This patch adds a new option, --resume-playback-check-mtime, which
validates that the file's mtime hasn't changed since the watch_later
configuration was saved. It does this by setting the watch_later
configuration to have the same mtime as the file after it is saved.

Switching back and forth between checking mtime and not checking mtime
works fine, as we only choose whether to compare based on it, but we
update the watch_later configuration mtime regardless of its value.
This commit is contained in:
Chris Down
2019-11-09 18:24:16 +00:00
committed by wm4
parent 1649ba15ab
commit e143966a76
6 changed files with 58 additions and 0 deletions

View File

@@ -714,6 +714,13 @@ Program Behavior
subdirectory (usually ``~/.config/mpv/watch_later/``).
See ``quit-watch-later`` input command.
``--resume-playback-check-mtime``
Only restore the playback position from the ``watch_later`` configuration
subdirectory (usually ``~/.config/mpv/watch_later/``) if the file's
modification time is the same as at the time of saving. This may prevent
skipping forward in files with the same name which have different content.
(Default: ``no``)
``--profile=<profile1,profile2,...>``
Use the given profile(s), ``--profile=help`` displays a list of the
defined profiles.