]> njoseph.me Git - nimcoon.git/commitdiff
peertube: Shift from UUID to short video id format
authorJoseph Nuthalapati <njoseph@riseup.net>
Fri, 3 Dec 2021 11:22:12 +0000 (16:52 +0530)
committerJoseph Nuthalapati <njoseph@riseup.net>
Fri, 3 Dec 2021 11:22:12 +0000 (16:52 +0530)
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
src/lib.nim
src/peertube.nim

index 3dcf78a3914b9d83196121ad09c273bb87253971..c88c4eda056716504e3b3b104ca4520308a9b8eb 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 =
index 36f1054ab2784091730af7325995478b099c2eab..946736f163d8110e66b7cc41faed9975ce1a2cf1 100644 (file)
@@ -5,11 +5,11 @@ import
   strformat,
   strutils
 
-let 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}"
+let PEERTUBE_REGEX = re"w\/[0-9a-zA-z]{22}"
 
 proc getPeerTubeMagnetLink*(url: string): string =
   ## Gets the magnet link of the best possible resolution from PeerTube
-  let uuid = url.substr(find(url, PEERTUBE_REGEX) + "videos/watch/".len)
+  let uuid = url.substr(find(url, PEERTUBE_REGEX) + "w/".len)
   let domainName = url.substr(8, find(url, '/', start=8) - 1)
   let apiURL = &"https://{domainName}/api/v1/videos/{uuid}"
   let client = newHttpClient()