Fix for proxied/geoblocked videos
This commit is contained in:
1 parent
7c24f36149
commit
215b4f4df2
3 files changed
+34
-8
No files matched your search
@@ -6,7 +6,7 @@ sub ShowVideoScreen(videoMetadata as object, videoSponsorBlock as object)
|
||||
SetCaptions(videoMetadata, m.videoPlayer, rowNode)
|
||||
m.videoPlayer.content = rowNode
|
||||
|
||||
ShowScreen(m.videoPlayer)
|
||||
ShowScreen(m.videoPlayer)
|
||||
m.videoPlayer.control = "play"
|
||||
m.videoPlayer.ObserveField("state", "OnVideoPlayerStateChange")
|
||||
m.videoPlayer.ObserveField("visible", "OnVideoVisibleChange")
|
||||
@@ -46,9 +46,31 @@ sub SetCaptions(videoMetadata as object, videoPlayer as object, contentNode as o
|
||||
}
|
||||
end sub
|
||||
|
||||
sub OnVideoPlayerStateChange()
|
||||
sub OnVideoPlayerStateChange()
|
||||
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"
|
||||
CloseScreen(m.videoPlayer)
|
||||
end if
|
||||
@@ -64,7 +86,7 @@ sub OnVideoVisibleChange()
|
||||
end if
|
||||
end sub
|
||||
|
||||
sub OnVideoPositionChange()
|
||||
sub OnVideoPositionChange()
|
||||
SkipSponsorBlockSections()
|
||||
end sub
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@ function GetVideoMetadata()
|
||||
videoMetadata = RokuYoutube.Services.Invidious.GetVideoMetadata(videoId)
|
||||
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: try direct videos first, before trying proxy, to avoid additional slowdowns
|
||||
videoUrl = RokuYoutube.Services.Invidious.GetVideoUrl(videoId, lastItag)
|
||||
videoUrl = RokuYoutube.Services.Invidious.GetVideoUrl(videoId, lastItag, false)
|
||||
|
||||
videoMetadata.formatStreams.push({
|
||||
itag: lastItag,
|
||||
url: videoUrl
|
||||
|
||||
@@ -57,8 +57,12 @@ namespace RokuYoutube.Services.Invidious
|
||||
end if
|
||||
end function
|
||||
|
||||
function GetVideoUrl(videoId as string, itag as string)
|
||||
return `${API_URL}/latest_version?id=${videoId}&itag=${itag}&local=true`
|
||||
function GetVideoUrl(videoId as string, itag as string, local as bool)
|
||||
url = `${API_URL}/latest_version?id=${videoId}&itag=${itag}`
|
||||
if local
|
||||
url = url + "&local=true"
|
||||
end if
|
||||
return url
|
||||
end function
|
||||
|
||||
function GetVideoMetadata(videoId as string)
|
||||
|
||||
Reference in new issue
Block a user