1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-22 19:34:14 +00:00

command: unescape URLs for ${filename} and ${media-title}

Undo URL percent encoding if the filename appears to be an URL. This
will fix display of the actual filename in some cases.

We don't put any effort into checking whether the URL is really percent
encoded, because we don't really know how the protocol handler is going
to interpret the URL. For stream_lavf, we probably can't know. Still,
from the perspective of this commit, it seems to make sense to assume
they are percent encoded.
This commit is contained in:
wm4 2013-09-04 14:31:08 +02:00
parent efc5ac17bf
commit b0f8e03f17

View File

@ -155,8 +155,13 @@ static int mp_property_filename(m_option_t *prop, int action, void *arg,
{
if (!mpctx->filename)
return M_PROPERTY_UNAVAILABLE;
char *f = (char *)mp_basename(mpctx->filename);
return m_property_strdup_ro(prop, action, arg, (*f) ? f : mpctx->filename);
char *filename = talloc_strdup(NULL, mpctx->filename);
if (mp_is_url(bstr0(filename)))
mp_url_unescape_inplace(filename);
char *f = (char *)mp_basename(filename);
int r = m_property_strdup_ro(prop, action, arg, f[0] ? f : filename);
talloc_free(filename);
return r;
}
static int mp_property_media_title(m_option_t *prop, int action, void *arg,