diff --git a/src/components/tasks/VideoDetailsLoaderTask.brs b/src/components/tasks/VideoDetailsLoaderTask.brs index f3e9b84f..ac6e818c 100644 --- a/src/components/tasks/VideoDetailsLoaderTask.brs +++ b/src/components/tasks/VideoDetailsLoaderTask.brs @@ -23,19 +23,7 @@ end sub function GetVideoMetadata() videoId = m.top.getField("videoid") - videoMetadata = RokuYoutube.Services.Invidious.GetVideoMetadata(videoId) - lastItag = videoMetadata.formatStreams[videoMetadata.formatStreams.Count() - 1].itag - - ' GetVideoUrl returns a url that redirects to the video stream - ' TODO: is this reliable? - videoUrl = RokuYoutube.Services.Invidious.GetVideoUrl(videoId, lastItag, false) - - videoMetadata.formatStreams.push({ - itag: lastItag, - url: videoUrl - }) - - return videoMetadata + return RokuYoutube.Services.Invidious.GetVideoMetadata(videoId) end function function GetVideoSponsorBlock() diff --git a/src/source/services/Invidious.bs b/src/source/services/Invidious.bs index 8e93285d..e00b4fa5 100644 --- a/src/source/services/Invidious.bs +++ b/src/source/services/Invidious.bs @@ -73,7 +73,17 @@ namespace RokuYoutube.Services.Invidious ' TODO: handle 500 {"error":"This video is unavailable"} if response.statuscode = 200 - return response.json + videoMetadata = response.json + lastItag = videoMetadata.formatStreams[videoMetadata.formatStreams.Count() - 1].itag + + ' GetVideoUrl returns a url that redirects to the video stream + ' TODO: is this reliable? + videoUrl = RokuYoutube.Services.Invidious.GetVideoUrl(videoId, lastItag, false) + + videoMetadata.formatStreams.push({ + itag: lastItag, + url: videoUrl + }) end if end function