Fix YouTube pattern
authorJoseph Nuthalapati <njoseph@riseup.net>
Tue, 24 Dec 2019 03:53:09 +0000 (09:23 +0530)
committerJoseph Nuthalapati <njoseph@riseup.net>
Tue, 24 Dec 2019 03:53:09 +0000 (09:23 +0530)
- Some manual refactoring. Couldn't get nimfmt to work

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
clitube.nim

index 1c30b92e75384ce5748eb904ee87a4b1b0f75abe..a9792c454956710cddbc4e15959c654510cfeaa5 100644 (file)
@@ -1,14 +1,16 @@
-import htmlparser
-import httpClient
-import parseopt
-import osproc
-import sequtils, sugar
-import strformat
-import std/[terminal]
-import strtabs
-import strutils
-import uri
-import xmltree
+import
+  htmlparser,
+  httpClient,
+  parseopt,
+  osproc,
+  sequtils,
+  sugar,
+  strformat,
+  std/[terminal],
+  strtabs,
+  strutils,
+  uri,
+  xmltree
 
 import preferences
 
@@ -55,22 +57,17 @@ for kind, key, value in getopt():
   of cmdEnd:
     discard
 
-
-if "?watch" in searchQuery or "videos/watch" in searchQuery :
+if "watch?" in searchQuery or "videos/watch" in searchQuery :
   discard execProcess(&"{player} {searchQuery}")
   quit(0)
-
-
-if searchQuery.startswith("magnet:"):
+elif searchQuery.startswith("magnet:"):
   discard execProcess(&"peerflix \"{searchQuery}\" --{player}")
   quit(0)
 
-
 let searchResults = extractTitlesAndUrls(getYoutubePage(searchQuery))
 
 let number =
-  if feelingLucky:
-    0
+  if feelingLucky: 0
   else:
     presentVideoOptions(searchResults)
     stdout.styledWrite(fgYellow, "Choose video number: ")