From dd04b04500a3e5262c25bf64990482f9b9ee74d8 Mon Sep 17 00:00:00 2001 From: amber Date: Sun, 19 Apr 2020 18:17:37 +0100 Subject: [PATCH] don't hardcode invidious url, add default to configtemplate --- configTemplate.js | 5 +++++ utils/music.js | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/configTemplate.js b/configTemplate.js index a165989..ed6b127 100644 --- a/configTemplate.js +++ b/configTemplate.js @@ -12,6 +12,11 @@ const config = { sentry: '' // sentry.io dsn }, + // Configurable API endpoints + endpoints: { + invidious: "https://invidious.snopyta.org/api/" + }, + // Users added to this embed get access to developer-level commands devs: [''], diff --git a/utils/music.js b/utils/music.js index 078661e..b1b6b8d 100644 --- a/utils/music.js +++ b/utils/music.js @@ -33,14 +33,14 @@ exports.getLinkFromID = function (id) { return 'https://www.youtube.com/watch?v=' + id } -exports.getVideoByQuery = async query => { +exports.getVideoByQuery = async function (client, query) { let res try { const id = await ytdl.getURLVideoID(query) - res = await fetch('https://invidious.snopyta.org/api/v1/videos/' + id) + res = await fetch(`${client.config.endpoints.invidious}v1/videos/${id}`) } catch (err) { - res = await fetch('https://invidious.snopyta.org/api/v1/search?q=' + encodeURIComponent(query)) + res = await fetch(`${client.config.endpoints.invidious}v1/search?q=${encodeURIComponent(query)}`) } const parsed = await res.json() @@ -71,7 +71,7 @@ exports.play = async function (client, message, query, ignoreQueue) { let videos if (!ignoreQueue) { - videos = await exports.getVideoByQuery(query) + videos = await exports.getVideoByQuery(client, query) if (!videos[1]) { if (!videos[0]) { video = videos