Use POST to update instances
This commit is contained in:
1 parent
16797a5144
commit
58ce258509
4 files changed
+22
-12
No files matched your search
@@ -103,7 +103,6 @@ function StartVideoDetailsTask(videoId as string)
|
||||
else if metadata.dashUrl <> invalid
|
||||
#if DASH_THUMBNAILS
|
||||
' Redirect to our server so we can inject thumbnails (storyboards) into the DASH manifest
|
||||
' TODO: make this optional, in case it breaks the DASH manifest
|
||||
contentNode.url = `http://${GetLocalIpAddress()}:8888/dash?v=${videoId}`
|
||||
#else
|
||||
contentNode.url = metadata.dashUrl
|
||||
|
||||
@@ -232,6 +232,14 @@ namespace Http
|
||||
m.buffer_index += data.len()
|
||||
return data
|
||||
end function
|
||||
|
||||
function Json() as dynamic
|
||||
if m.body = invalid
|
||||
return invalid
|
||||
end if
|
||||
|
||||
return ParseJson(m.body)
|
||||
end function
|
||||
end class
|
||||
|
||||
end namespace
|
||||
@@ -5,17 +5,15 @@ namespace Http
|
||||
function new()
|
||||
super()
|
||||
|
||||
' TODO: use POST once supported
|
||||
m.Get("/invidious/set-instances", function(context as object) as boolean
|
||||
m.Post("/invidious/instances", function(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
instances = []
|
||||
if request.query.DoesExist("instances")
|
||||
instances = request.query["instances"]
|
||||
if GetInterface(instances, "ifArray") = invalid
|
||||
instances = [instances]
|
||||
end if
|
||||
instances = request.Json()
|
||||
|
||||
if GetInterface(instances, "ifArray") = invalid
|
||||
response.Default(400, "Expected json array")
|
||||
return true
|
||||
end if
|
||||
|
||||
for i = 0 to instances.Count() - 1
|
||||
|
||||
+8
-3
@@ -210,9 +210,14 @@ ${JSON.stringify(window.appState.device, null, 2)}
|
||||
.filter(a => !!a)
|
||||
.map(a => a.innerText);
|
||||
|
||||
args = instances.map(instance => `instances=${instance}`).join("&")
|
||||
|
||||
fetch(`/invidious/set-instances?${args}`)
|
||||
fetch('/invidious/instances',
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
method: "POST",
|
||||
body: JSON.stringify(instances)
|
||||
})
|
||||
.then(function (response) {
|
||||
alert("Instances updated. Restart Playlet to reflect changes.")
|
||||
window.location.reload();
|
||||
|
||||
Reference in new issue
Block a user