Add a fullScreen option
authorJoseph Nuthalapati <njoseph@riseup.net>
Fri, 10 Jan 2020 15:58:47 +0000 (21:28 +0530)
committerJoseph Nuthalapati <njoseph@riseup.net>
Fri, 10 Jan 2020 15:59:58 +0000 (21:29 +0530)
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
clitube.nim

index 9e73275dcb32806f34105c3331c30857bfd74eb6..f69813dbf4566702e67cacd161e6ca545e80e026 100644 (file)
@@ -17,7 +17,7 @@ import preferences
 
 type
   SearchResult = tuple[title: string, url: string]
-  CommandLineOptions = tuple[searchQuery: string, musicOnly: bool, feelingLucky: bool]
+  CommandLineOptions = tuple[searchQuery: string, musicOnly: bool, feelingLucky: bool, fullScreen: bool]
 
 let logger = newConsoleLogger()
 setLogFilter(lvlInfo)
@@ -35,6 +35,7 @@ proc parseOptions(): CommandLineOptions =
     searchQuery = ""
     musicOnly = false
     feelingLucky = false
+    fullScreen = false
 
   for kind, key, value in getopt():
     case kind
@@ -44,10 +45,11 @@ proc parseOptions(): CommandLineOptions =
       case key
       of "m", "music": musicOnly = true
       of "l", "lucky": feelingLucky = true
+      of "f", "full-screen": fullScreen = true
     of cmdEnd:
       discard
 
-  return (searchQuery, musicOnly, feelingLucky)
+  return (searchQuery, musicOnly, feelingLucky, fullScreen)
 
 proc getYoutubePage(searchQuery: string): string =
   let queryParam = encodeUrl(searchQuery)
@@ -79,7 +81,7 @@ proc directPlay(searchQuery: string, player: string) =
 proc main() =
   let
     player = selectMediaPlayer()
-    (searchQuery, musicOnly, feelingLucky) = parseOptions()
+    (searchQuery, musicOnly, feelingLucky, fullScreen) = parseOptions()
 
   if searchQuery.startswith("https:") or searchQuery.startswith("magnet:"):
     directPlay(searchQuery, player)
@@ -100,6 +102,12 @@ proc main() =
   if musicOnly:
     command.add("--no-video")
 
+  if fullScreen:
+    if player == "cvlc":
+      command.add("--fullscreen")
+    if player == "mpv":
+      command.add("--fs")
+
   # Play the video using the preferred/available media player
   play(command.join(" "))