41 lines
1.1 KiB
Plaintext
41 lines
1.1 KiB
Plaintext
import "pkg:/components/Services/Invidious/InvidiousService.bs"
|
|
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
|
|
|
|
@asynctask
|
|
function ChannelContentTask(input as object) as object
|
|
contentNode = input.content
|
|
invidiousNode = input.invidious
|
|
|
|
if m.top.cancel
|
|
contentNode.loadState = FeedLoadState.None
|
|
return invalid
|
|
end if
|
|
|
|
service = new Invidious.InvidiousService(invidiousNode)
|
|
response = service.GetChannel(contentNode.authorId, m.top.cancellation)
|
|
|
|
if m.top.cancel
|
|
contentNode.loadState = FeedLoadState.None
|
|
return invalid
|
|
end if
|
|
|
|
metadata = response.Json()
|
|
|
|
if not response.IsSuccess() or metadata = invalid
|
|
contentNode.loadState = FeedLoadState.Error
|
|
return {
|
|
success: false,
|
|
error: response.ErrorMessage()
|
|
}
|
|
end if
|
|
|
|
instance = service.GetInstance()
|
|
InvidiousContent.ToChannelContentNode(contentNode, metadata, instance)
|
|
|
|
contentNode.loadState = FeedLoadState.Loaded
|
|
|
|
return {
|
|
success: true
|
|
}
|
|
end function
|