72 lines
2.1 KiB
Plaintext
72 lines
2.1 KiB
Plaintext
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
|
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
|
|
|
@asynctask
|
|
function VideoContentTaskDev(input as object) as object
|
|
titleLabel = input.titleLabel
|
|
secondaryTitleLabel = input.secondaryTitleLabel
|
|
backgroundPoster = input.backgroundPoster
|
|
contentNode = input.content
|
|
invidiousNode = input.invidious
|
|
|
|
titleLabel.text = contentNode.title
|
|
secondaryTitleLabel.text = contentNode.secondaryTitle
|
|
|
|
videoId = contentNode.videoId
|
|
|
|
if StringUtils.IsNullOrEmpty(videoId)
|
|
throw "Can't load video information: videoId is missing"
|
|
end if
|
|
|
|
service = new Invidious.InvidiousService(invidiousNode)
|
|
instance = service.GetInstance()
|
|
|
|
backgroundPoster.uri = `${instance}/vi/${videoId}/maxresdefault.jpg`
|
|
|
|
response = service.GetVideoMetadata(videoId, { cancellation: m.top.cancellation })
|
|
|
|
if m.top.cancel
|
|
return invalid
|
|
end if
|
|
|
|
metadata = response.Json()
|
|
|
|
if not response.IsSuccess() or metadata = invalid
|
|
return {
|
|
success: false
|
|
error: response.ErrorMessage()
|
|
}
|
|
end if
|
|
|
|
contentNode.title = metadata.title
|
|
titleLabel.text = metadata.title
|
|
|
|
secondaryTitle = `${metadata.author}`
|
|
viewCount = InvidiousContent.VideoGetViewCountText(metadata)
|
|
if not StringUtils.IsNullOrEmpty(viewCount)
|
|
secondaryTitle = `${secondaryTitle} • ${viewCount}`
|
|
end if
|
|
pubslishedText = InvidiousContent.VideoGetPublishedText(metadata)
|
|
if not StringUtils.IsNullOrEmpty(pubslishedText)
|
|
secondaryTitle = `${secondaryTitle} • ${pubslishedText}`
|
|
end if
|
|
|
|
contentNode.secondaryTitle = secondaryTitle
|
|
secondaryTitleLabel.text = secondaryTitle
|
|
contentNode.live = metadata.liveNow
|
|
|
|
streamUrls = [`http://127.0.0.1:8888/api/dash?v=${metadata.videoId}`]
|
|
contentNode.url = streamUrls[0]
|
|
|
|
contentNode.addFields({
|
|
metadata: metadata
|
|
' StreamUrls is taken
|
|
playletStreamUrls: streamUrls
|
|
playletStreamUrlIndex: 0
|
|
})
|
|
|
|
return {
|
|
success: true
|
|
}
|
|
end function
|