]> njoseph.me Git - nimcoon.git/commitdiff
Store player config options in a hashtable
authorJoseph Nuthalapati <njoseph@riseup.net>
Fri, 10 Jan 2020 17:29:29 +0000 (22:59 +0530)
committerJoseph Nuthalapati <njoseph@riseup.net>
Fri, 10 Jan 2020 17:29:29 +0000 (22:59 +0530)
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
README.md
config.nim [new file with mode: 0644]
nimcoon.nim
preferences.nim [deleted file]

index 2823d1e2d1a8da0a837f7ab06186f4497ab0d626..daf4ca6c54f0f60daae679c4fad551137a5ee3fa 100644 (file)
--- 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.
 
 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 (file)
index 0000000..f55bc9d
--- /dev/null
@@ -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
index f69813dbf4566702e67cacd161e6ca545e80e026..c838b343f66568c6e054d4f05de5bd7c55e20590 100644 (file)
@@ -10,10 +10,11 @@ import
   std/[terminal],
   strtabs,
   strutils,
   std/[terminal],
   strtabs,
   strutils,
+  tables,
   uri,
   xmltree
 
   uri,
   xmltree
 
-import preferences
+import config
 
 type
   SearchResult = tuple[title: string, url: string]
 
 type
   SearchResult = tuple[title: string, url: string]
@@ -100,13 +101,10 @@ proc main() =
   var command = @[player, searchResults[number].url]
 
   if musicOnly:
   var command = @[player, searchResults[number].url]
 
   if musicOnly:
-    command.add("--no-video")
+    command.add(playerOptions[player]["musicOnly"])
 
   if fullScreen:
 
   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(" "))
 
   # Play the video using the preferred/available media player
   play(command.join(" "))
diff --git a/preferences.nim b/preferences.nim
deleted file mode 100644 (file)
index a9ef411..0000000
+++ /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
-