From 3e8a2ca89b77fa832dbf8f59e35be528fda78b51 Mon Sep 17 00:00:00 2001 From: Chris Plaatjes Date: Wed, 22 Feb 2023 22:25:32 -0500 Subject: [PATCH] Added ttDownloader --- ttDownloader.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 ttDownloader.ts diff --git a/ttDownloader.ts b/ttDownloader.ts new file mode 100644 index 0000000..822ee49 --- /dev/null +++ b/ttDownloader.ts @@ -0,0 +1,32 @@ +import uu from 'url-unshort'; + +export class VidDownload { + public async UnshortenUrl(string) { + let shorturl = new URL(string); + let longurl; + + try { + const url = await uu.expand(shorturl); + longurl = url; + } catch (err) { + console.log("URL Unshortening failed"); + return; + } + + return longurl; + } + + public CreateDownloadLink(string) { + + } + + public isValidUrl(string) { + let url; + try { + url = new URL(string); + } catch (_) { + return false; + } + return url.protocol === "https:"; + } +} \ No newline at end of file