Add option to download video
[nimcoon.git] / src / nimcoon.nim
index 2db5ece023a706ac3312e2a73419cdf22282b355..2ddafc94d4384968048b25f2665ea83eb7d413bd 100644 (file)
@@ -76,10 +76,20 @@ proc main() =
       args.add(searchResults[number].url)
       return args
 
+  func buildVideoDownloadArgs(number: int): seq[string] =
+    {.noSideEffect.}:
+      var args = @["-f", "best", "-o"]
+      let downloadLocation = &"'{expandTilde(videoDownloadDirectory)}/%(title)s.%(ext)s'"
+      args.add(downloadLocation)
+      args.add(searchResults[number].url)
+      return args
+
   proc handleUserInput(number: int) =
     if options["download"]:
       if options["musicOnly"]:
         download(buildMusicDownloadArgs(number), searchResults[number].title)
+      else:
+        download(buildVideoDownloadArgs(number), searchResults[number].title)
     else:
       play(player, buildPlayerArgs(number), searchResults[number].title)