-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor Video Queue * Video queue and playlists * Web app casting * queue playlist notification * VideoQueueView work * restore properties * changes
- Loading branch information
Showing
58 changed files
with
1,168 additions
and
928 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
playlet-lib/src/components/ContentNode/PlaylistContentNode.bs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import "pkg:/components/Dialog/DialogUtils.bs" | ||
import "pkg:/components/VideoFeed/FeedLoadState.bs" | ||
import "pkg:/source/AsyncTask/AsyncTask.bs" | ||
import "pkg:/source/AsyncTask/Tasks.bs" | ||
import "pkg:/source/utils/ErrorUtils.bs" | ||
import "pkg:/source/utils/Logging.bs" | ||
|
||
function LoadPlaylistPage(invidiousNode as object) as void | ||
LoadPlaylist(invidiousNode, true) | ||
end function | ||
|
||
function LoadPlaylistAll(invidiousNode as object) as void | ||
LoadPlaylist(invidiousNode, false) | ||
end function | ||
|
||
function LoadPlaylist(invidiousNode as object, singlePage as boolean) as void | ||
if m.contentTask <> invalid | ||
m.contentTask.cancel = true | ||
end if | ||
|
||
loadState = m.top.loadState | ||
if loadState = FeedLoadState.Loading or loadState = FeedLoadState.Loaded | ||
return | ||
end if | ||
|
||
m.top.loadState = FeedLoadState.Loading | ||
m.contentTask = AsyncTask.Start(Tasks.PlaylistContentTask, { | ||
content: m.top | ||
invidious: invidiousNode | ||
singlePage: singlePage | ||
}, OnPlaylistContentTaskResult) | ||
end function | ||
|
||
function OnPlaylistContentTaskResult(output as object) as void | ||
m.contentTask = invalid | ||
|
||
if output.cancelled | ||
return | ||
end if | ||
|
||
if not output.success or not output.result.success | ||
' output.error for unhandled exception | ||
error = output.error | ||
if error = invalid | ||
' output.result.error for network errors | ||
error = output.result.error | ||
end if | ||
error = ErrorUtils.Format(error) | ||
LogError(error) | ||
playlistId = output.task.input.content.playlistId | ||
message = `Failed to load playlist ${playlistId}\n${error}` | ||
DialogUtils.ShowDialog(message, "Playlist load fail", true) | ||
return | ||
end if | ||
end function |
3 changes: 3 additions & 0 deletions
3
playlet-lib/src/components/ContentNode/PlaylistContentNode.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
playlet-lib/src/components/ContentNode/PlaylistContentTask.bs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import "pkg:/components/Services/Invidious/InvidiousService.bs" | ||
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs" | ||
import "pkg:/components/VideoFeed/FeedLoadState.bs" | ||
|
||
@asynctask | ||
function PlaylistContentTask(input as object) as object | ||
contentNode = input.content | ||
invidiousNode = input.invidious | ||
singlePage = input.singlePage | ||
|
||
if m.top.cancel | ||
contentNode.loadState = FeedLoadState.None | ||
return invalid | ||
end if | ||
|
||
service = new Invidious.InvidiousService(invidiousNode) | ||
instance = service.GetInstance() | ||
|
||
while true | ||
index = contentNode.getChildCount() | ||
response = service.GetPlaylist(contentNode.playlistId, index, 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 | ||
|
||
InvidiousContent.ToPlaylistContentNode(contentNode, metadata, instance) | ||
childCount = contentNode.getChildCount() | ||
|
||
if metadata.videos.Count() = 0 or childCount >= metadata.videoCount | ||
contentNode.loadState = FeedLoadState.Loaded | ||
return { | ||
success: true | ||
} | ||
else | ||
contentNode.loadState = FeedLoadState.LoadedPage | ||
if singlePage | ||
return { | ||
success: true | ||
} | ||
end if | ||
end if | ||
end while | ||
|
||
return invalid | ||
end function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.