From: Joseph Nuthalapati Date: Fri, 3 Dec 2021 11:22:12 +0000 (+0530) Subject: peertube: Shift from UUID to short video id format X-Git-Tag: 0.9.0~2 X-Git-Url: https://njoseph.me/gitweb/nimcoon.git/commitdiff_plain/62e4d409fe321dff3ef519f88df839c458fcfa49 peertube: Shift from UUID to short video id format Signed-off-by: Joseph Nuthalapati --- diff --git a/src/lib.nim b/src/lib.nim index 3dcf78a..c88c4ed 100644 --- a/src/lib.nim +++ b/src/lib.nim @@ -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 = diff --git a/src/peertube.nim b/src/peertube.nim index 36f1054..946736f 100644 --- a/src/peertube.nim +++ b/src/peertube.nim @@ -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()