Fix for proxied/geoblocked videos
This commit is contained in:
1 parent
7c24f36149
commit
215b4f4df2
3 files changed
+31
-5
No files matched your search
@@ -49,6 +49,28 @@ end sub
|
|||||||
sub OnVideoPlayerStateChange()
|
sub OnVideoPlayerStateChange()
|
||||||
state = m.videoPlayer.state
|
state = m.videoPlayer.state
|
||||||
|
|
||||||
|
' A hack to see if we could use the proxy here
|
||||||
|
if state = "error"
|
||||||
|
errorInfo = m.videoPlayer.errorInfo
|
||||||
|
if errorInfo.category = "http"
|
||||||
|
url = m.videoPlayer.content.url
|
||||||
|
if url.InStr("local=true") = -1
|
||||||
|
print(`Video ${url} failed to play. Trying a proxy (local=true)`)
|
||||||
|
m.videoPlayer.content.url = url + "&local=true"
|
||||||
|
' This video errored, and is about to finish, so don't close the video yet
|
||||||
|
' TODO: perhaps creating a second player is better?
|
||||||
|
m.ignoreNextFinishedState = true
|
||||||
|
m.videoPlayer.control = "play"
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
|
||||||
|
if state = "finished" and m.ignoreNextFinishedState
|
||||||
|
m.ignoreNextFinishedState = false
|
||||||
|
return
|
||||||
|
end if
|
||||||
|
|
||||||
if state = "error" or state = "finished"
|
if state = "error" or state = "finished"
|
||||||
CloseScreen(m.videoPlayer)
|
CloseScreen(m.videoPlayer)
|
||||||
end if
|
end if
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ function GetVideoMetadata()
|
|||||||
videoMetadata = RokuYoutube.Services.Invidious.GetVideoMetadata(videoId)
|
videoMetadata = RokuYoutube.Services.Invidious.GetVideoMetadata(videoId)
|
||||||
lastItag = videoMetadata.formatStreams[videoMetadata.formatStreams.Count() - 1].itag
|
lastItag = videoMetadata.formatStreams[videoMetadata.formatStreams.Count() - 1].itag
|
||||||
|
|
||||||
' GetVideoUrl returns a url with the local=true, which is proxied through the instance
|
' GetVideoUrl returns a url that redirects to the video stream
|
||||||
' TODO: is this reliable?
|
' TODO: is this reliable?
|
||||||
' TODO: try direct videos first, before trying proxy, to avoid additional slowdowns
|
videoUrl = RokuYoutube.Services.Invidious.GetVideoUrl(videoId, lastItag, false)
|
||||||
videoUrl = RokuYoutube.Services.Invidious.GetVideoUrl(videoId, lastItag)
|
|
||||||
videoMetadata.formatStreams.push({
|
videoMetadata.formatStreams.push({
|
||||||
itag: lastItag,
|
itag: lastItag,
|
||||||
url: videoUrl
|
url: videoUrl
|
||||||
|
|||||||
@@ -57,8 +57,12 @@ namespace RokuYoutube.Services.Invidious
|
|||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetVideoUrl(videoId as string, itag as string)
|
function GetVideoUrl(videoId as string, itag as string, local as bool)
|
||||||
return `${API_URL}/latest_version?id=${videoId}&itag=${itag}&local=true`
|
url = `${API_URL}/latest_version?id=${videoId}&itag=${itag}`
|
||||||
|
if local
|
||||||
|
url = url + "&local=true"
|
||||||
|
end if
|
||||||
|
return url
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetVideoMetadata(videoId as string)
|
function GetVideoMetadata(videoId as string)
|
||||||
|
|||||||
Reference in new issue
Block a user