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
|
end if
|
||||||
|
|
||||||
if metadata.formatStreams.Count() > 0
|
if metadata.formatStreams.Count() > 0
|
||||||
stream = metadata.formatStreams[metadata.formatStreams.Count() - 1]
|
playletStreamUrls.push(Invidious.GetVideoStreamUrl(videoId, false))
|
||||||
itag = stream.itag
|
playletStreamUrls.push(Invidious.GetVideoStreamUrl(videoId, true))
|
||||||
|
|
||||||
playletStreamUrls.push(Invidious.GetVideoUrl(videoId, itag, false))
|
|
||||||
playletStreamUrls.push(Invidious.GetVideoUrl(videoId, itag, true))
|
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
|||||||
@@ -19,17 +19,13 @@ namespace Http
|
|||||||
|
|
||||||
instance = InvidiousSettings.GetSelectedInstance()
|
instance = InvidiousSettings.GetSelectedInstance()
|
||||||
metadata = router.GetVideoMetadata(context, v)
|
metadata = router.GetVideoMetadata(context, v)
|
||||||
dashUrl = `${instance}/api/manifest/dash/id/${v}`
|
dashUrl = Invidious.GetVideoDashUrl(v, local <> invalid)
|
||||||
|
|
||||||
if metadata = invalid and local = invalid
|
if metadata = invalid and local = invalid
|
||||||
response.Redirect(dashUrl)
|
response.Redirect(dashUrl)
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if local <> invalid
|
|
||||||
dashUrl = `${dashUrl}?local=${local}`
|
|
||||||
end if
|
|
||||||
|
|
||||||
resp = Requests().get(dashUrl, { parseJson: false })
|
resp = Requests().get(dashUrl, { parseJson: false })
|
||||||
text = resp.text ?? ""
|
text = resp.text ?? ""
|
||||||
if resp.statuscode = 200 and local = "true"
|
if resp.statuscode = 200 and local = "true"
|
||||||
|
|||||||
@@ -42,15 +42,24 @@ namespace Invidious
|
|||||||
return invalid
|
return invalid
|
||||||
end function
|
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()
|
instance = InvidiousSettings.GetSelectedInstance()
|
||||||
url = `${instance}/latest_version?id=${videoId}&itag=${itag}`
|
url = `${instance}/latest_version?id=${videoId}`
|
||||||
if local
|
if local
|
||||||
url = url + "&local=true"
|
url = url + "&local=true"
|
||||||
end if
|
end if
|
||||||
return url
|
return url
|
||||||
end function
|
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
|
function GetVideoMetadata(videoId as string) as object
|
||||||
instance = InvidiousSettings.GetSelectedInstance()
|
instance = InvidiousSettings.GetSelectedInstance()
|
||||||
url = `${instance}${Invidious.VIDEOS_ENDPOINT}/${videoId}`
|
url = `${instance}${Invidious.VIDEOS_ENDPOINT}/${videoId}`
|
||||||
|
|||||||
Reference in new issue
Block a user