From: Joseph Nuthalapati Date: Fri, 10 Jan 2020 17:29:29 +0000 (+0530) Subject: Store player config options in a hashtable X-Git-Tag: 0.1.0~25 X-Git-Url: https://njoseph.me/gitweb/nimcoon.git/commitdiff_plain/f7735b43cbeb05c3e30cc9d2d0df3197fa1c0eb9 Store player config options in a hashtable Signed-off-by: Joseph Nuthalapati --- diff --git a/README.md b/README.md index 2823d1e..daf4ca6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Nim Coon +# NimCoon Play videos from YouTube and PeerTube from the command line using your preferred desktop media player. diff --git a/config.nim b/config.nim new file mode 100644 index 0000000..f55bc9d --- /dev/null +++ b/config.nim @@ -0,0 +1,21 @@ +import tables + +# Your configuration here. + +# Supported video players in order of preference. +# Should be able to play YouTube videos directly. +let supportedPlayers* = ["mpv", "cvlc"] + +# Only show these many results +let limit* = 10 + +# Some NimCoon options mapped to player options +let playerOptions* = { "mpv": { + "musicOnly": "--no-video", + "fullScreen": "--fullscreen" + }.toTable, + "cvlc": { + "musicOnly": "--no-video", + "fullScreen": "--fs" + }.toTable + }.toTable diff --git a/nimcoon.nim b/nimcoon.nim index f69813d..c838b34 100644 --- a/nimcoon.nim +++ b/nimcoon.nim @@ -10,10 +10,11 @@ import std/[terminal], strtabs, strutils, + tables, uri, xmltree -import preferences +import config type SearchResult = tuple[title: string, url: string] @@ -100,13 +101,10 @@ proc main() = var command = @[player, searchResults[number].url] if musicOnly: - command.add("--no-video") + command.add(playerOptions[player]["musicOnly"]) if fullScreen: - if player == "cvlc": - command.add("--fullscreen") - if player == "mpv": - command.add("--fs") + command.add(playerOptions[player]["fullScreen"]) # Play the video using the preferred/available media player play(command.join(" ")) diff --git a/preferences.nim b/preferences.nim deleted file mode 100644 index a9ef411..0000000 --- a/preferences.nim +++ /dev/null @@ -1,9 +0,0 @@ -# Your preferences here. - -# Supported video players in order of preference. -# Should be able to play YouTube videos directly. -let supportedPlayers* = ["mpv", "cvlc"] - -# Only show these many results -let limit* = 10 -