From f2a0eeb799c8d401f6ffe27981e757d98af3d1fe Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Thu, 21 Sep 2023 17:07:24 +0300 Subject: [PATCH] more youtube links --- squeebot.repo.json | 2 +- urlreply/plugin.json | 2 +- urlreply/plugin.ts | 44 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/squeebot.repo.json b/squeebot.repo.json index 5bd8458..292697c 100644 --- a/squeebot.repo.json +++ b/squeebot.repo.json @@ -39,7 +39,7 @@ }, { "name": "urlreply", - "version": "1.1.0" + "version": "1.1.1" }, { "name": "utility", diff --git a/urlreply/plugin.json b/urlreply/plugin.json index a8046a0..4cad07e 100644 --- a/urlreply/plugin.json +++ b/urlreply/plugin.json @@ -2,7 +2,7 @@ "main": "plugin.js", "name": "urlreply", "description": "Fetch titles from web pages, specifically made for IRC", - "version": "1.1.0", + "version": "1.1.1", "tags": ["irc"], "dependencies": [], "npmDependencies": ["cheerio@^1.0.0-rc.10"] diff --git a/urlreply/plugin.ts b/urlreply/plugin.ts index cddb676..3f47542 100644 --- a/urlreply/plugin.ts +++ b/urlreply/plugin.ts @@ -20,7 +20,7 @@ interface URLHandler { let urlHandlers: { [key: string]: URLHandler } = {}; let htmlHandlers: any[] = []; -const urlRegex = /(((ftp|https?):\/\/)[-\w@:%_+.~#?,&//=]+)/g; +const urlRegex = /(((ftp|https?):\/\/)[-\w@:%_+.~#?,&//=()]+)/g; function findUrls(text: string): string[] { const source = (text || '').toString(); @@ -343,6 +343,48 @@ class URLReplyPlugin extends Plugin { } ); + this.registerHandler( + this.name, + 'youtube.com/shorts/', + async (url: urllib.URL, msg: IMessage, data: any) => { + const det = url.pathname.split('/')[2]; + + if (!det) { + return false; + } + + return getYoutubeFromVideo.apply(this, [this, det, url, msg]); + } + ); + + this.registerHandler( + this.name, + 'youtube.com/live/', + async (url: urllib.URL, msg: IMessage, data: any) => { + const det = url.pathname.split('/')[2]; + + if (!det) { + return false; + } + + return getYoutubeFromVideo.apply(this, [this, det, url, msg]); + } + ); + + this.registerHandler( + this.name, + 'youtube.com/v/', + async (url: urllib.URL, msg: IMessage, data: any) => { + const det = url.pathname.split('/')[2]; + + if (!det) { + return false; + } + + return getYoutubeFromVideo.apply(this, [this, det, url, msg]); + } + ); + // Dailymotion this.registerHandler( this.name,