]> njoseph.me Git - nimcoon.git/blobdiff - src/lib.nim
Get rid of Peerflix. Only use Webtorrent.
[nimcoon.git] / src / lib.nim
index 3dcf78a3914b9d83196121ad09c273bb87253971..4064ae43cdbdde02acbf5722317597f4a2d11fa1 100644 (file)
@@ -17,7 +17,7 @@ import
 
 let
   processOptions = {poStdErrToStdOut, poUsePath} # Add poEchoCmd to debug
-  PEERTUBE_REGEX = re"videos\/watch\/[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}"
+  PEERTUBE_REGEX = re"w\/[0-9a-zA-z]{22}"
 
 
 proc isInstalled(program: string): bool =
@@ -82,14 +82,12 @@ proc play*(player: string, options: Table[string, bool], url: string, title: str
 proc directPlay*(url: string, player: string, options: Table[string, bool]) =
   let url =
     if find(url, PEERTUBE_REGEX) != -1 and "webtorrent".isInstalled:
-      getPeerTubeMagnetLink(url)
+      getPeerTubeMagnetLink(url, options["musicOnly"])
     else: url
   if url.startswith("magnet:") or url.endswith(".torrent"):
     if options["musicOnly"]:
-      # TODO Replace with WebTorrent once it supports media player options
-      discard execShellCmd(&"peerflix '{url}' -a --{player} -- --no-video")
+      discard execShellCmd(&"webtorrent '{url}' --{player} --player-args='--no-video'")
     else:
-      # WebTorrent is so much faster!
       discard execProcess("webtorrent", args=[url, &"--{player}"], options=processOptions)
   else:
     play(player, options, url)