configurable ryd url

This commit is contained in:
Evert Prants 2022-12-01 13:02:54 +02:00
parent 51df207701
commit 05db7ca20f
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
4 changed files with 24 additions and 8 deletions

View File

@ -39,7 +39,7 @@
}, },
{ {
"name": "urlreply", "name": "urlreply",
"version": "1.0.6" "version": "1.0.8"
}, },
{ {
"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.0.6", "version": "1.0.8",
"tags": ["irc"], "tags": ["irc"],
"dependencies": [], "dependencies": [],
"npmDependencies": ["cheerio@^1.0.0-rc.10"] "npmDependencies": ["cheerio@^1.0.0-rc.10"]

View File

@ -124,6 +124,7 @@ async function getYoutubeFromVideo(
full: urllib.URL, full: urllib.URL,
msg: IMessage): Promise<boolean> { msg: IMessage): Promise<boolean> {
const gtoken = plugin.config.get('tokens.google'); const gtoken = plugin.config.get('tokens.google');
const dislikeAPIBase = plugin.config.get('api.returnyoutubedislike');
if (!gtoken) { if (!gtoken) {
return false; return false;
@ -144,13 +145,15 @@ async function getYoutubeFromVideo(
return false; return false;
} }
const dislikeAPI = `https://returnyoutubedislikeapi.com/votes?videoId=${id}`;
let dislikeData; let dislikeData;
try { if (dislikeAPIBase) {
dislikeData = await httpGET(dislikeAPI); const dislikeAPI = `${dislikeAPIBase}/votes?videoId=${id}`;
dislikeData = JSON.parse(dislikeData); try {
} catch (e) { dislikeData = await httpGET(dislikeAPI);
dislikeData = null; dislikeData = JSON.parse(dislikeData);
} catch (e) {
dislikeData = null;
}
} }
const vid = data.items[0]; const vid = data.items[0];
@ -219,6 +222,9 @@ async function getYoutubeFromVideo(
tokens: { tokens: {
google: null, google: null,
soundcloud: null soundcloud: null
},
api: {
returnyoutubedislike: 'https://returnyoutubedislikeapi.com'
} }
}) })
class URLReplyPlugin extends Plugin { class URLReplyPlugin extends Plugin {

View File

@ -18,6 +18,16 @@
"description": "Soundcloud API token" "description": "Soundcloud API token"
} }
} }
},
"api": {
"type": "object",
"description": "API URLs",
"properties": {
"returnyoutubedislike": {
"type": "string",
"description": "API URL for ReturnYoutubeDislike"
}
}
} }
}, },
"required": ["tokens"] "required": ["tokens"]