From 6403ecdf8794ca920f98133e84bc281647ccc661 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 30 Oct 2012 19:32:57 +0100 Subject: commands: make media-title property return filename in default case Instead of the full path. --- command.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/command.c b/command.c index 5b615ef5be..e6295bc8a0 100644 --- a/command.c +++ b/command.c @@ -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) -- cgit v1.2.3