1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-25 04:38:01 +00:00

commands: make media-title property return filename in default case

Instead of the full path.
This commit is contained in:
wm4 2012-10-30 19:32:57 +01:00
parent e5f96e9845
commit 6403ecdf87

View File

@ -167,15 +167,26 @@ static int mp_property_path(m_option_t *prop, int action, void *arg,
return m_property_strdup_ro(prop, action, arg, mpctx->filename);
}
static int mp_property_filename(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
{
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);
}
static int mp_property_media_title(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
{
char *name = mpctx->filename;
char *name = NULL;
if (mpctx->resolve_result)
name = mpctx->resolve_result->title;
if (!name)
return M_PROPERTY_UNAVAILABLE;
return m_property_strdup_ro(prop, action, arg, name);
if (name && name[0]) {
return m_property_strdup_ro(prop, action, arg, name);
} else {
return mp_property_filename(prop, action, arg, mpctx);
}
}
static int mp_property_stream_path(m_option_t *prop, int action, void *arg,
@ -187,16 +198,6 @@ static int mp_property_stream_path(m_option_t *prop, int action, void *arg,
return m_property_strdup_ro(prop, action, arg, stream->url);
}
/// filename without path (RO)
static int mp_property_filename(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
{
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);
}
/// Demuxer name (RO)
static int mp_property_demuxer(m_option_t *prop, int action, void *arg,
MPContext *mpctx)