diff options
author | wm4 <wm4@nowhere> | 2012-10-30 19:32:57 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-10-30 20:13:28 +0100 |
commit | 6403ecdf8794ca920f98133e84bc281647ccc661 (patch) | |
tree | 735971e87da1dc06b843566c939eb099f84d8a58 /command.c | |
parent | e5f96e98450562d03bf4486073eed6b262dd967f (diff) | |
download | mpv-6403ecdf8794ca920f98133e84bc281647ccc661.tar.bz2 mpv-6403ecdf8794ca920f98133e84bc281647ccc661.tar.xz |
commands: make media-title property return filename in default case
Instead of the full path.
Diffstat (limited to 'command.c')
-rw-r--r-- | command.c | 29 |
1 files changed, 15 insertions, 14 deletions
@@ -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) |