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",
"version": "1.0.6"
"version": "1.0.8"
},
{
"name": "utility",

View File

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

View File

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

View File

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