static char *mp_get_playback_resume_config_filename(struct MPContext *mpctx, const char *fname) { struct MPOpts *opts = mpctx->opts; char *res = NULL; void *tmp = talloc_new(NULL); const char *realpath = fname; bstr bfname = bstr0(fname); if (!mp_is_url(bfname)) { if (opts->ignore_path_in_watch_later_config) { realpath = mp_basename(fname); } else { char *cwd = mp_getcwd(tmp); if (!cwd) goto exit; realpath = mp_path_join(tmp, cwd, fname); } } if (bstr_startswith0(bfname, "dvd://") && opts->dvd_opts && opts->dvd_opts->device) realpath = talloc_asprintf(tmp, "%s - %s", realpath, opts->dvd_opts->device); if ((bstr_startswith0(bfname, "br://") || bstr_startswith0(bfname, "bd://") || bstr_startswith0(bfname, "bluray://")) && opts->bluray_device) realpath = talloc_asprintf(tmp, "%s - %s", realpath, opts->bluray_device); uint8_t md5[16]; av_md5_sum(md5, realpath, strlen(realpath)); char *conf = talloc_strdup(tmp, ""); for (int i = 0; i < 16; i++) conf = talloc_asprintf_append(conf, "%02X", md5[i]); if (!mpctx->cached_watch_later_configdir) { char *wl_dir = mpctx->opts->watch_later_directory; if (wl_dir && wl_dir[0]) { mpctx->cached_watch_later_configdir = mp_get_user_path(mpctx, mpctx->global, wl_dir); } } if (!mpctx->cached_watch_later_configdir) { mpctx->cached_watch_later_configdir = mp_find_user_config_file(mpctx, mpctx->global, MP_WATCH_LATER_CONF); } if (mpctx->cached_watch_later_configdir) res = mp_path_join(NULL, mpctx->cached_watch_later_configdir, conf); exit: talloc_free(tmp); return res; }
static char *mp_get_playback_resume_config_filename(struct mpv_global *global, const char *fname) { struct MPOpts *opts = global->opts; char *res = NULL; void *tmp = talloc_new(NULL); const char *realpath = fname; bstr bfname = bstr0(fname); if (!mp_is_url(bfname)) { if (opts->ignore_path_in_watch_later_config) { realpath = mp_basename(fname); } else { char *cwd = mp_getcwd(tmp); if (!cwd) goto exit; realpath = mp_path_join(tmp, bstr0(cwd), bstr0(fname)); } } if (bstr_startswith0(bfname, "dvd://")) realpath = talloc_asprintf(tmp, "%s - %s", realpath, opts->dvd_device); if (bstr_startswith0(bfname, "br://") || bstr_startswith0(bfname, "bd://") || bstr_startswith0(bfname, "bluray://")) realpath = talloc_asprintf(tmp, "%s - %s", realpath, opts->bluray_device); uint8_t md5[16]; av_md5_sum(md5, realpath, strlen(realpath)); char *conf = talloc_strdup(tmp, ""); for (int i = 0; i < 16; i++) conf = talloc_asprintf_append(conf, "%02X", md5[i]); res = talloc_asprintf(tmp, MP_WATCH_LATER_CONF "/%s", conf); res = mp_find_config_file(NULL, global, res); if (!res) { res = mp_find_config_file(tmp, global, MP_WATCH_LATER_CONF); if (res) res = talloc_asprintf(NULL, "%s/%s", res, conf); } exit: talloc_free(tmp); return res; }
static char *mp_get_playback_resume_config_filename(struct mpv_global *global, const char *fname) { char *res = NULL; void *tmp = talloc_new(NULL); const char *realpath = fname; bstr bfname = bstr0(fname); if (!mp_is_url(bfname)) { char *cwd = mp_getcwd(tmp); if (!cwd) goto exit; realpath = mp_path_join(tmp, bstr0(cwd), bstr0(fname)); } #if HAVE_DVDREAD || HAVE_DVDNAV if (bstr_startswith0(bfname, "dvd://")) realpath = talloc_asprintf(tmp, "%s - %s", realpath, dvd_device); #endif #if HAVE_LIBBLURAY if (bstr_startswith0(bfname, "br://") || bstr_startswith0(bfname, "bd://") || bstr_startswith0(bfname, "bluray://")) realpath = talloc_asprintf(tmp, "%s - %s", realpath, bluray_device); #endif uint8_t md5[16]; av_md5_sum(md5, realpath, strlen(realpath)); char *conf = talloc_strdup(tmp, ""); for (int i = 0; i < 16; i++) conf = talloc_asprintf_append(conf, "%02X", md5[i]); conf = talloc_asprintf(tmp, "%s/%s", MP_WATCH_LATER_CONF, conf); res = mp_find_user_config_file(NULL, global, conf); exit: talloc_free(tmp); return res; }