@@ -209,21 +209,13 @@ char *mp_get_playback_resume_dir(struct MPContext *mpctx)
209209}
210210
211211static char * mp_get_playback_resume_config_filename (struct MPContext * mpctx ,
212- const char * fname )
212+ const char * path )
213213{
214214 struct MPOpts * opts = mpctx -> opts ;
215215 char * res = NULL ;
216216 void * tmp = talloc_new (NULL );
217- const char * path = NULL ;
218- if (mp_is_url (bstr0 (fname ))) {
219- path = fname ;
220- } else if (opts -> ignore_path_in_watch_later_config ) {
221- path = mp_basename (fname );
222- } else {
223- path = mp_normalize_path (tmp , fname );
224- if (!path )
225- goto exit ;
226- }
217+ if (opts -> ignore_path_in_watch_later_config && !mp_is_url (bstr0 (path )))
218+ path = mp_basename (path );
227219 uint8_t md5 [16 ];
228220 av_md5_sum (md5 , path , strlen (path ));
229221 char * conf = talloc_strdup (tmp , "" );
@@ -234,8 +226,6 @@ static char *mp_get_playback_resume_config_filename(struct MPContext *mpctx,
234226 if (wl_dir && wl_dir [0 ])
235227 res = mp_path_join (NULL , wl_dir , conf );
236228 talloc_free (wl_dir );
237-
238- exit :
239229 talloc_free (tmp );
240230 return res ;
241231}
@@ -310,18 +300,13 @@ void mp_write_watch_later_conf(struct MPContext *mpctx)
310300{
311301 struct playlist_entry * cur = mpctx -> playing ;
312302 char * conffile = NULL ;
313- void * ctx = talloc_new (NULL );
314303
315304 if (!cur )
316305 goto exit ;
317306
318- char * path = mp_normalize_path (ctx , cur -> filename );
319- if (!path )
320- goto exit ;
321-
322307 struct demuxer * demux = mpctx -> demuxer ;
323308
324- conffile = mp_get_playback_resume_config_filename (mpctx , path );
309+ conffile = mp_get_playback_resume_config_filename (mpctx , cur -> filename );
325310 if (!conffile )
326311 goto exit ;
327312
@@ -337,7 +322,7 @@ void mp_write_watch_later_conf(struct MPContext *mpctx)
337322 goto exit ;
338323 }
339324
340- write_filename (mpctx , file , path );
325+ write_filename (mpctx , file , cur -> filename );
341326
342327 bool write_start = true;
343328 double pos = get_playback_time (mpctx );
@@ -374,34 +359,32 @@ void mp_write_watch_later_conf(struct MPContext *mpctx)
374359 }
375360 fclose (file );
376361
377- if (mpctx -> opts -> position_check_mtime && !mp_is_url (bstr0 (path )) &&
378- !copy_mtime (path , conffile ))
362+ if (mpctx -> opts -> position_check_mtime && !mp_is_url (bstr0 (cur -> filename )) &&
363+ !copy_mtime (cur -> filename , conffile ))
379364 {
380365 MP_WARN (mpctx , "Can't copy mtime from %s to %s\n" , cur -> filename ,
381366 conffile );
382367 }
383368
384- write_redirects_for_parent_dirs (mpctx , path );
369+ write_redirects_for_parent_dirs (mpctx , cur -> filename );
385370
386371 // Also write redirect entries for a playlist that mpv expanded if the
387372 // current entry is a URL, this is mostly useful for playing multiple
388373 // archives of images, e.g. with mpv 1.zip 2.zip and quit-watch-later
389374 // on 2.zip, write redirect entries for 2.zip, not just for the archive://
390375 // URL.
391- if (cur -> playlist_path && mp_is_url (bstr0 (path ))) {
392- char * playlist_path = mp_normalize_path (ctx , cur -> playlist_path );
393- write_redirect (mpctx , playlist_path );
394- write_redirects_for_parent_dirs (mpctx , playlist_path );
376+ if (cur -> playlist_path && mp_is_url (bstr0 (cur -> filename ))) {
377+ write_redirect (mpctx , cur -> playlist_path );
378+ write_redirects_for_parent_dirs (mpctx , cur -> playlist_path );
395379 }
396380
397381exit :
398382 talloc_free (conffile );
399- talloc_free (ctx );
400383}
401384
402385void mp_delete_watch_later_conf (struct MPContext * mpctx , const char * file )
403386{
404- char * path = mp_normalize_path (NULL , file ? file : mpctx -> filename ) ;
387+ char * path = file ? mp_normalize_path (NULL , file ) : mpctx -> filename ;
405388 if (!path )
406389 goto exit ;
407390
0 commit comments