-# Nim Coon
+# NimCoon
Play videos from YouTube and PeerTube from the
command line using your preferred desktop media player.
--- /dev/null
+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
std/[terminal],
strtabs,
strutils,
+ tables,
uri,
xmltree
-import preferences
+import config
type
SearchResult = tuple[title: string, url: string]
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(" "))
+++ /dev/null
-# 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
-