more generic youtube matcher
This commit is contained in:
parent
9e0feffc3c
commit
51df207701
@ -39,7 +39,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "urlreply",
|
"name": "urlreply",
|
||||||
"version": "1.0.5"
|
"version": "1.0.6"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "utility",
|
"name": "utility",
|
||||||
|
@ -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.0.5",
|
"version": "1.0.6",
|
||||||
"tags": ["irc"],
|
"tags": ["irc"],
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"npmDependencies": ["cheerio@^1.0.0-rc.10"]
|
"npmDependencies": ["cheerio@^1.0.0-rc.10"]
|
||||||
|
@ -245,7 +245,7 @@ class URLReplyPlugin extends Plugin {
|
|||||||
htmlHandlers = [];
|
htmlHandlers = [];
|
||||||
|
|
||||||
// YouTube
|
// YouTube
|
||||||
this.registerHandler(this.name, 'youtube.com/', async (url: urllib.URL, msg: IMessage, data: any) => {
|
this.registerHandler(this.name, '/watch\\?v=', async (url: urllib.URL, msg: IMessage, data: any) => {
|
||||||
const det = url.searchParams.get('v');
|
const det = url.searchParams.get('v');
|
||||||
|
|
||||||
if (!det) {
|
if (!det) {
|
||||||
@ -304,7 +304,7 @@ class URLReplyPlugin extends Plugin {
|
|||||||
// Find handlers matching this URL
|
// Find handlers matching this URL
|
||||||
for (const handler in urlHandlers) {
|
for (const handler in urlHandlers) {
|
||||||
const obj = urlHandlers[handler];
|
const obj = urlHandlers[handler];
|
||||||
if (url.indexOf(handler) !== -1 || !obj.action) {
|
if (!!url.match(handler) || !obj.action) {
|
||||||
try {
|
try {
|
||||||
const urlParsed = new urllib.URL(url);
|
const urlParsed = new urllib.URL(url);
|
||||||
|
|
||||||
@ -313,6 +313,9 @@ class URLReplyPlugin extends Plugin {
|
|||||||
logger.error(e.stack);
|
logger.error(e.stack);
|
||||||
matched = false;
|
matched = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matched) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,7 +323,9 @@ class URLReplyPlugin extends Plugin {
|
|||||||
// If there were no matches, pull the title of the website
|
// If there were no matches, pull the title of the website
|
||||||
if (!matched) {
|
if (!matched) {
|
||||||
try {
|
try {
|
||||||
const data = await httpGET(url, {}, true);
|
const data = await httpGET(url, {
|
||||||
|
Accept: 'text/html,application/xhtml+xml,application/xml'
|
||||||
|
}, true);
|
||||||
if (!data) { return; }
|
if (!data) { return; }
|
||||||
|
|
||||||
const full = cheerio.load(data);
|
const full = cheerio.load(data);
|
||||||
|
Loading…
Reference in New Issue
Block a user