From a78fce46765c75a47512cd4d638b66fa9a40bd31 Mon Sep 17 00:00:00 2001 From: Julian Date: Thu, 7 May 2015 00:18:35 +0200 Subject: stats: don't add superfluous EOL characters Previously we unnecessarily added newline characters at the end. Only noticeable when printed on terminal, though. --- player/lua/stats.lua | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/player/lua/stats.lua b/player/lua/stats.lua index e7e119a4f1..961a326217 100644 --- a/player/lua/stats.lua +++ b/player/lua/stats.lua @@ -86,8 +86,6 @@ function add_file(s) if append_property(s, "file", "cache-used", "Cache:") then append_property_inline(s, "file", "demuxer-cache-duration", "+", " sec", true, true) end - - s.file = s.file .. o.nl .. o.nl end @@ -116,8 +114,6 @@ function add_video(s) append_property(s, "video", "video-params/primaries", "Primaries:") append_property(s, "video", "video-params/colorlevels", "Levels:") append_property(s, "video", "packet-video-bitrate", "Bitrate:", " kbps") - - s.video = s.video .. o.nl .. o.nl end @@ -132,8 +128,6 @@ function add_audio(s) append_property(s, "audio", "audio-samplerate", "Sample Rate:") append_property(s, "audio", "audio-channels", "Channels:") append_property(s, "audio", "packet-audio-bitrate", "Bitrate:", " kbps") - - s.audio = s.audio .. o.nl .. o.nl end @@ -199,7 +193,16 @@ end function join_stats(s) - return s.header .. s.file .. s.video .. s.audio + r = s.header .. s.file + + if s.video and s.video ~= "" then + r = r .. o.nl .. o.nl .. s.video + end + if s.audio and s.audio ~= "" then + r = r .. o.nl .. o.nl .. s.audio + end + + return r end @@ -210,13 +213,13 @@ end function has_video() local r = mp.get_property("video") - return r ~= nil and r ~= "no" and r ~= "" + return r and r ~= "no" and r ~= "" end function has_audio() local r = mp.get_property("audio") - return r ~= nil and r ~= "no" and r ~= "" + return r and r ~= "no" and r ~= "" end -- cgit v1.2.3