Skip to content

Commit f37e372

Browse files
committed
cplayer: Fix %f expansion in screenshot template
Do not call mp_basename() again. 'filename' is already the basename according to the man page. Plus, it makes it inconsistent with %{filename}, which gets no special treatment (basename) in the property expansion case. Previous behavior resluts in an empty string if 'filename' is a URL that ends with a '/', which in turn would lead to 'screenshot-dir' being ignored or overwritten with '/' in case of nesting screenshot dirs per file, e.g.: $ mpv \ --screenshot-dir='~/tmp/mpv-shots' \ --screenshot-template='%f/%P' \ https://example.org/video/ This happens with ytdl-hook on some sites. I think this points to a related bug in mp_basename, because directories do have a basename. A trailing '/' should be stripped IMO. And there must be some inconsistency in how the filename property gets set, because it is simply being set to the whole URL, so some other kind of basename function or a different fallback is used.
1 parent 28ef6b7 commit f37e372

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

player/screenshot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static char *create_fname(struct MPContext *mpctx, char *template,
177177
case 'F': {
178178
char *video_file = NULL;
179179
if (mpctx->filename)
180-
video_file = mp_basename(mpctx->filename);
180+
video_file = mpctx->filename;
181181

182182
if (!video_file)
183183
video_file = "NO_FILE";

0 commit comments

Comments
 (0)