more youtube links

This commit is contained in:
Evert Prants 2023-09-21 17:07:24 +03:00
parent ea2d033978
commit f2a0eeb799
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
3 changed files with 45 additions and 3 deletions

View File

@ -39,7 +39,7 @@
}, },
{ {
"name": "urlreply", "name": "urlreply",
"version": "1.1.0" "version": "1.1.1"
}, },
{ {
"name": "utility", "name": "utility",

View File

@ -2,7 +2,7 @@
"main": "plugin.js", "main": "plugin.js",
"name": "urlreply", "name": "urlreply",
"description": "Fetch titles from web pages, specifically made for IRC", "description": "Fetch titles from web pages, specifically made for IRC",
"version": "1.1.0", "version": "1.1.1",
"tags": ["irc"], "tags": ["irc"],
"dependencies": [], "dependencies": [],
"npmDependencies": ["cheerio@^1.0.0-rc.10"] "npmDependencies": ["cheerio@^1.0.0-rc.10"]

View File

@ -20,7 +20,7 @@ interface URLHandler {
let urlHandlers: { [key: string]: URLHandler } = {}; let urlHandlers: { [key: string]: URLHandler } = {};
let htmlHandlers: any[] = []; let htmlHandlers: any[] = [];
const urlRegex = /(((ftp|https?):\/\/)[-\w@:%_+.~#?,&//=]+)/g; const urlRegex = /(((ftp|https?):\/\/)[-\w@:%_+.~#?,&//=()]+)/g;
function findUrls(text: string): string[] { function findUrls(text: string): string[] {
const source = (text || '').toString(); 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 // Dailymotion
this.registerHandler( this.registerHandler(
this.name, this.name,