Refactor format stream url
This commit is contained in:
1 parent
5c43bdf904
commit
b7e6a1ea83
3 files changed
+14
-12
No files matched your search
@@ -136,11 +136,8 @@ function OnVideoDetailsTaskResults(output as object) as void
|
||||
end if
|
||||
|
||||
if metadata.formatStreams.Count() > 0
|
||||
stream = metadata.formatStreams[metadata.formatStreams.Count() - 1]
|
||||
itag = stream.itag
|
||||
|
||||
playletStreamUrls.push(Invidious.GetVideoUrl(videoId, itag, false))
|
||||
playletStreamUrls.push(Invidious.GetVideoUrl(videoId, itag, true))
|
||||
playletStreamUrls.push(Invidious.GetVideoStreamUrl(videoId, false))
|
||||
playletStreamUrls.push(Invidious.GetVideoStreamUrl(videoId, true))
|
||||
end if
|
||||
end if
|
||||
|
||||
|
||||
@@ -19,17 +19,13 @@ namespace Http
|
||||
|
||||
instance = InvidiousSettings.GetSelectedInstance()
|
||||
metadata = router.GetVideoMetadata(context, v)
|
||||
dashUrl = `${instance}/api/manifest/dash/id/${v}`
|
||||
dashUrl = Invidious.GetVideoDashUrl(v, local <> invalid)
|
||||
|
||||
if metadata = invalid and local = invalid
|
||||
response.Redirect(dashUrl)
|
||||
return true
|
||||
end if
|
||||
|
||||
if local <> invalid
|
||||
dashUrl = `${dashUrl}?local=${local}`
|
||||
end if
|
||||
|
||||
resp = Requests().get(dashUrl, { parseJson: false })
|
||||
text = resp.text ?? ""
|
||||
if resp.statuscode = 200 and local = "true"
|
||||
|
||||
@@ -42,15 +42,24 @@ namespace Invidious
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function GetVideoUrl(videoId as string, itag as string, local as boolean) as string
|
||||
function GetVideoStreamUrl(videoId as string, local as boolean) as string
|
||||
instance = InvidiousSettings.GetSelectedInstance()
|
||||
url = `${instance}/latest_version?id=${videoId}&itag=${itag}`
|
||||
url = `${instance}/latest_version?id=${videoId}`
|
||||
if local
|
||||
url = url + "&local=true"
|
||||
end if
|
||||
return url
|
||||
end function
|
||||
|
||||
function GetVideoDashUrl(videoId as string, local as boolean) as string
|
||||
instance = InvidiousSettings.GetSelectedInstance()
|
||||
url = `${instance}/api/manifest/dash/id/${videoId}`
|
||||
if local
|
||||
url = url + "?local=true"
|
||||
end if
|
||||
return url
|
||||
end function
|
||||
|
||||
function GetVideoMetadata(videoId as string) as object
|
||||
instance = InvidiousSettings.GetSelectedInstance()
|
||||
url = `${instance}${Invidious.VIDEOS_ENDPOINT}/${videoId}`
|
||||
|
||||
Reference in new issue
Block a user