]> njoseph.me Git - nimcoon.git/blobdiff - nimcoon.nim
Be a nimble package
[nimcoon.git] / nimcoon.nim
diff --git a/nimcoon.nim b/nimcoon.nim
deleted file mode 100644 (file)
index 8b1ba59..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-import
-  parseopt,
-  std/[terminal],
-  strutils
-
-import config
-import lib
-
-proc parseOptions(): CommandLineOptions =
-  var
-    searchQuery = ""
-    musicOnly = false
-    feelingLucky = false
-    fullScreen = false
-
-  for kind, key, value in getopt():
-    case kind
-    of cmdArgument:
-      searchQuery = key
-    of cmdShortOption, cmdLongOption:
-      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, fullScreen)
-
-
-proc main() =
-  let
-    player = selectMediaPlayer()
-    (searchQuery, musicOnly, feelingLucky, fullScreen) = parseOptions()
-
-  if searchQuery.startswith("https:") or searchQuery.startswith("magnet:"):
-    directPlay(searchQuery, player)
-    quit(0)
-
-  let searchResults = extractTitlesAndUrls(getYoutubePage(searchQuery))
-
-  proc getUserInput(): string =
-    if feelingLucky: "0"
-    else:
-      presentVideoOptions(searchResults[..(limit-1)])
-      stdout.styledWrite(fgYellow, "Choose video number: ")
-      readLine(stdin)
-
-  # This is a pure function with no side effects
-  func buildArgs(number: int): seq[string] =
-    var args = @[searchResults[number].url]
-    if musicOnly: args.add("--no-video")
-    if fullScreen: args.add("--fullscreen")
-    return args
-
-  while(true):
-    let userInput = getUserInput()
-
-    if userInput == "all":
-      for number in 0..(len(searchResults)):
-        play(player, buildArgs(number), searchResults[number].title)
-
-    if userInput == "q":
-      break
-
-    # Play the video using the preferred/available media player
-    let videoNumber = parseInt(userInput)
-    play(player, buildArgs(videoNumber), searchResults[videoNumber].title)
-    if feelingLucky:
-      break
-
-
-when isMainModule:
-  main()