Fetch instance list from instances.invidio.us
This commit is contained in:
parent
c55429ac49
commit
806494f5e0
|
@ -2,6 +2,7 @@ const {render, redirect} = require("pinski/plugins")
|
||||||
const db = require("../utils/db")
|
const db = require("../utils/db")
|
||||||
const {getToken, getUser} = require("../utils/getuser")
|
const {getToken, getUser} = require("../utils/getuser")
|
||||||
const constants = require("../utils/constants")
|
const constants = require("../utils/constants")
|
||||||
|
const {getInstances} = require("../background/instances")
|
||||||
const validate = require("../utils/validate")
|
const validate = require("../utils/validate")
|
||||||
const V = validate.V
|
const V = validate.V
|
||||||
|
|
||||||
|
@ -10,7 +11,8 @@ module.exports = [
|
||||||
route: "/settings", methods: ["GET"], code: async ({req}) => {
|
route: "/settings", methods: ["GET"], code: async ({req}) => {
|
||||||
const user = getUser(req)
|
const user = getUser(req)
|
||||||
const settings = user.getSettings()
|
const settings = user.getSettings()
|
||||||
return render(200, "pug/settings.pug", {constants, user, settings})
|
const instances = getInstances()
|
||||||
|
return render(200, "pug/settings.pug", {constants, user, settings, instances})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
const {request} = require("../utils/request")
|
||||||
|
|
||||||
|
let globalList = []
|
||||||
|
|
||||||
|
function execute() {
|
||||||
|
return request("https://instances.invidio.us/instances.json?sort_by=health").then(res => res.json()).then(list => {
|
||||||
|
list = list.filter(i => i[1].type === "https").map(i => i[1].uri)
|
||||||
|
globalList = list
|
||||||
|
}).catch(error => {
|
||||||
|
console.error(error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInstances() {
|
||||||
|
return globalList
|
||||||
|
}
|
||||||
|
|
||||||
|
execute()
|
||||||
|
setInterval(() => {
|
||||||
|
execute()
|
||||||
|
}, 60*60*1000)
|
||||||
|
|
||||||
|
module.exports.getInstances = getInstances
|
|
@ -30,12 +30,7 @@ block content
|
||||||
form(method="post" action="/settings")
|
form(method="post" action="/settings")
|
||||||
+fieldset("Settings")
|
+fieldset("Settings")
|
||||||
|
|
||||||
+input("instance", "Instance", "url", constants.user_settings.instance.default, false, [
|
+input("instance", "Instance", "url", constants.user_settings.instance.default, false, instances)
|
||||||
"https://invidious.snopyta.org",
|
|
||||||
"https://invidious.13ad.de",
|
|
||||||
"https://watch.nettohikari.com",
|
|
||||||
"https://invidious.fdn.fr"
|
|
||||||
])
|
|
||||||
|
|
||||||
+select("save_history", "Watched videos history", false, [
|
+select("save_history", "Watched videos history", false, [
|
||||||
{value: "0", text: "Don't store"},
|
{value: "0", text: "Don't store"},
|
||||||
|
|
Loading…
Reference in New Issue