summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-10-30 19:32:57 +0100
committerwm4 <wm4@nowhere>2012-10-30 20:13:28 +0100
commit6403ecdf8794ca920f98133e84bc281647ccc661 (patch)
tree735971e87da1dc06b843566c939eb099f84d8a58
parente5f96e98450562d03bf4486073eed6b262dd967f (diff)
downloadmpv-6403ecdf8794ca920f98133e84bc281647ccc661.tar.bz2
mpv-6403ecdf8794ca920f98133e84bc281647ccc661.tar.xz
commands: make media-title property return filename in default case
Instead of the full path.
-rw-r--r--command.c29
1 files 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)