From: Joseph Nuthalapati Date: Fri, 13 Dec 2019 18:11:31 +0000 (+0530) Subject: Use less dangerous ways of joining strings X-Git-Tag: 0.1.0~41 X-Git-Url: https://njoseph.me/gitweb/nimcoon.git/commitdiff_plain/a2319a3ffe086b965e3925c811c8b7bdfef49f86?ds=sidebyside Use less dangerous ways of joining strings Signed-off-by: Joseph Nuthalapati --- diff --git a/clitube.nim b/clitube.nim index 3714c13..a964291 100644 --- a/clitube.nim +++ b/clitube.nim @@ -53,7 +53,6 @@ for kind, key, value in getopt(): of cmdEnd: discard -let noVideo = if musicOnly: "--no-video" else: "" if "https://www.youtube.com" in searchQuery: discard execProcess(&"{player} {searchQuery}") @@ -69,5 +68,10 @@ let number = parseInt(readLine(stdin)) styledEcho "\n", fgGreen, "Playing ", styleBright, fgMagenta, searchResults[number].title +var command = @[player, searchResults[number].url] + +if musicOnly: + command.add("--no-video") + # Play the video using the preferred/available media player -discard execProcess(&"{player} {noVideo} {searchResults[number].url}") +discard execProcess(command.join(" ")) diff --git a/preferences.nim b/preferences.nim index 00daf48..a9ef411 100644 --- a/preferences.nim +++ b/preferences.nim @@ -2,7 +2,7 @@ # Supported video players in order of preference. # Should be able to play YouTube videos directly. -let supportedPlayers* = ["cvlc", "mpv"] +let supportedPlayers* = ["mpv", "cvlc"] # Only show these many results let limit* = 10