diff --git a/CHANGELOG.md b/CHANGELOG.md index dd527a50..ff9613b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Support for casting from the YouTube app (also known as Lounge API, or LeanBack) + - Connect to Playlet from the YouTube mobile app or from certain browsers (such as Chrome) + - Connect to Playlet from local network, or through the TV code. + - On the cast dialog in your YouTube mobile app, you might see two listings for the same device. E.g. `Roku TV` and `Playlet on Roku TV`. Use the `Playlet on` one to cast to Playlet, and the other one to cast to the regular YouTube TV app. + - The functionality is still experiemntal, and has some limitations. To name a few: + - The queue does not perfectly sync between the mobile app and Playlet, espeically if it gets modified by the web app or in Playlet. + - Many functions (such as d-pad controls, setting volume) are not working due to OS limitations + - Many functions (such as changing the subtitle settings) are not currently implemented + - **ATTENTION**: This feature is not very privacy friendly. When connected to a lounge, all network traffic (videos played, queued, etc) go through YouTube servers. For this reason, certain measures are taken: + - While Playlet broadcasts its casting capabilities to the local network, it does not connect to a network for the first time until: + - A device connects to Playlet (using DIAL/Connect using Wi-Fi) + - A `Link with TV code` is generated, by visiting the `Remote` -> `Link with TV code` tab. + - Playlet disconnects from previous lounge sessions on start, and joins a new one instead of one continous session. In other words, restarting Playlet will disconnect your second device. This is a feature, not a bug. + - Playlet does not expose device details, and uses a randomly generated id on each start, instead of consistent device id. + ### Changed +- The queue no longer contains playlists. When a playlist is added to the queue, the entire playlist is loaded. + - It can take a few seconds to load large playlist before it can be added to the queue + - This is done to be more compatible more the lounge, which does not contain "Playlists in the queue" concept. +- The `Web App` tab is now called `Remote`. It can be used to open the web app, or connect using Lounge (cast from YouTube) - Removed `fields` from Invidious requests, as per [https://github.com/iv-org/invidious/pull/4276](https://github.com/iv-org/invidious/pull/4276) +- The `POST /api/queue/` no longer returns the current queue. Instead it returns a 204. ## [0.19.2] - 2024-02-11 diff --git a/PRIVACY.md b/PRIVACY.md index 8f1c9d22..d9157a79 100644 --- a/PRIVACY.md +++ b/PRIVACY.md @@ -1,39 +1,52 @@ # PRIVACY POLICY ## Playlet + Playlet, the Roku app, does not collect any user information whatsoever. In fact, it does not have any servers capable of collecting any form of data. Playlet does not show advertising, whether personalized or non personalized. ## Invidious + Playlet may request information from one or more [Invidious](https://invidious.io/) -servers, depending on user configuration. With these requests, absolutely no -user data is collected, and only the bare minimum and necessary information +servers, depending on user configuration. With these requests, absolutely no +user data is collected, and only the bare minimum and necessary information is sent, which is used to enable the viewing of content. Please note that some of the [Invidious](https://invidious.io/) servers used could be public instances hosted by volenteers. These instances are available -[here](https://api.invidious.io/). +[here](https://api.invidious.io/). While invidious does no data collection by default, and it is in fact built to -be privacy driven, but in theory, from a playlet request it is possible to -know the IP address of a user, the identifiers of watched video, and search +be privacy driven, but in theory, from a playlet request it is possible to +know the IP address of a user, the identifiers of watched video, and search keywords. In case the user has privacy concerns, they can host their own Invidious instance and use it from Playlet. ## SponsorBlock + Playlet may request information from a [SponsorBlock](https://github.com/ajayyy/SponsorBlock) server, in order to get sponsor sections for requested videos to watch. -With these requests, absolutely no -user data is collected, and only the bare minimum and necessary information +With these requests, absolutely no +user data is collected, and only the bare minimum and necessary information is sent, which is used to enable the viewing of content. -Playlet uses hashing when requesting video metadata, which obfuscates +Playlet uses hashing when requesting video metadata, which obfuscates the video id requested. This is a SponsorBlock privacy feature that protects user privacy. Additionally, Playlet may send a "skipped" event to SponsorBlock, to indicate -that a section of a video has been skipped. This event does not have any -tracking information attached to it, and it is anonymous. It is merely to -indicate to contributers how much their contributions are being used in the wild. +that a section of a video has been skipped. This event does not have any +tracking information attached to it, and it is anonymous. It is merely to +indicate to contributers how much their contributions are being used in the wild. + +## LeanBack + +LeanBack, also known as Lounge API, also known as "cast from phone". Is a feature that Playlet implmements as a convenience to allow users to use a separate device to browse and cast videos. +When this feature is used, all traffic related to the videos being watched, added to the queue, and the video player state is routed through YouTube servers. + +Playlet tries to preserve user privacy, to the best of its ability, by implementing several techniques, such as randomizing device id, using a fresh session on each start, and only providing necessary fields for the feature to function. +Additionally, Playlet does not join a session/lounge, until a device is attempting to connect using DIAL (**DI**scovery **A**nd **L**aunch spec), or when a `Link with TV code` is generated, by visiting the appropriate settings page. + +If you have privacy concerns and do not wish to use this functionality, simply do not connect from a local network using the YouTube app or the browser, and do not visit the `Link with TV code` tab. diff --git a/docs/playlet-web-api.yml b/docs/playlet-web-api.yml index 9976d9a2..b9a7d1a6 100644 --- a/docs/playlet-web-api.yml +++ b/docs/playlet-web-api.yml @@ -140,9 +140,9 @@ paths: description: No Content /api/queue: get: - summary: Get play queue + summary: Get video queue description: Get the current videos in the queue. - operationId: getPlayQueue + operationId: getVideoQueue responses: "200": description: OK @@ -151,56 +151,43 @@ paths: schema: type: object properties: - index: - type: integer - playlistIndex: - type: integer items: type: array items: - $ref: "#/components/schemas/PlayQueueObject" + $ref: "#/components/schemas/VideoQueueObject" + index: + type: integer + nowPlaying: + $ref: "#/components/schemas/VideoQueueObject" post: - summary: Add to play queue + summary: Add to video queue description: Add a video or a playlist to the queue. - operationId: addToPlayQueue + operationId: addToVideoQueue requestBody: content: application/json: schema: - $ref: "#/components/schemas/PlayQueueObject" + $ref: "#/components/schemas/VideoQueueObject" responses: - "200": - description: OK - content: - application/json: - schema: - type: object - properties: - index: - type: integer - playlistIndex: - type: integer - items: - type: array - items: - $ref: "#/components/schemas/PlayQueueObject" + "204": + description: No Content delete: - summary: Clear play queue - description: Clear the play queue. - operationId: clearPlayQueue + summary: Clear video queue + description: Clear the video queue. + operationId: clearVideoQueue responses: "204": description: No Content /api/queue/play: post: - summary: Play video or playlist + summary: Play video description: Play a video or playlist. This adds the video or playlist to the current position in the queue and plays it. - operationId: playPlayQueue + operationId: playVideoQueue requestBody: content: application/json: schema: - $ref: "#/components/schemas/PlayQueueObject" + $ref: "#/components/schemas/VideoQueueObject" responses: "204": description: No Content @@ -574,7 +561,7 @@ components: sponsorblock.show_notifications: type: boolean # TODO:P1 add the rest of properties - PlayQueueObject: + VideoQueueObject: type: object properties: videoId: diff --git a/playlet-lib/src/components/AppController/AppController.bs b/playlet-lib/src/components/AppController/AppController.bs index 0cb4ceb8..14203fb2 100644 --- a/playlet-lib/src/components/AppController/AppController.bs +++ b/playlet-lib/src/components/AppController/AppController.bs @@ -1,7 +1,7 @@ import "pkg:/components/Dialog/DialogUtils.bs" import "pkg:/components/Navigation/LongPress.bs" -import "pkg:/components/PlayQueue/PlayQueueViewUtils.bs" -import "pkg:/components/VideoPlayer/VideoUtils.bs" +import "pkg:/components/VideoQueue/VideoQueueUtils.bs" +import "pkg:/components/VideoQueue/VideoQueueViewUtils.bs" import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/StringUtils.bs" @@ -86,13 +86,13 @@ function onKeyEvent(key as string, press as boolean) as boolean end if if key = OPTIONS_LONG_PRESS_KEY and press - LogInfo("Opening PlayQueueView") - PlayQueueViewUtils.Open(m.top.playQueue, m.top) + LogInfo("Opening VideoQueueView") + VideoQueueViewUtils.Open(m.top.videoQueue, m.top) return true end if if key = "options" and not press - if VideoUtils.ToggleVideoPictureInPicture() + if VideoQueueUtils.ToggleVideoPictureInPicture(m.top.videoQueue) return true end if end if @@ -102,26 +102,26 @@ function onKeyEvent(key as string, press as boolean) as boolean end if if key = "play" - if VideoUtils.TogglePause() + if VideoQueueUtils.TogglePause(m.top.videoQueue) return true end if end if if key = "pause" - if VideoUtils.PauseVideo() + if VideoQueueUtils.Pause(m.top.videoQueue) return true end if end if if key = "playonly" - if VideoUtils.ResumeVideo() + if VideoQueueUtils.Play(m.top.videoQueue) return true end if end if if key = "back" - if VideoUtils.IsVideoPlayerOpen() and not VideoUtils.IsVideoPlayerFullScreen() - if VideoUtils.ToggleVideoPictureInPicture() + if VideoQueueUtils.IsVideoPlayerOpen(m.top.videoQueue) and not VideoQueueUtils.IsVideoPlayerFullScreen(m.top.videoQueue) + if VideoQueueUtils.ToggleVideoPictureInPicture(m.top.videoQueue) return true end if end if diff --git a/playlet-lib/src/components/AppController/AppController.xml b/playlet-lib/src/components/AppController/AppController.xml index d3191815..bca38108 100644 --- a/playlet-lib/src/components/AppController/AppController.xml +++ b/playlet-lib/src/components/AppController/AppController.xml @@ -2,7 +2,7 @@ - + diff --git a/playlet-lib/src/components/ContentNode/ChannelContentNode.bs b/playlet-lib/src/components/ContentNode/ChannelContentNode.bs index bff24f53..2c3d80ec 100644 --- a/playlet-lib/src/components/ContentNode/ChannelContentNode.bs +++ b/playlet-lib/src/components/ContentNode/ChannelContentNode.bs @@ -5,9 +5,6 @@ import "pkg:/source/AsyncTask/Tasks.bs" import "pkg:/source/utils/ErrorUtils.bs" import "pkg:/source/utils/Logging.bs" -function Init() -end function - function LoadChannel(invidiousNode as object) as void if m.contentTask <> invalid m.contentTask.cancel = true diff --git a/playlet-lib/src/components/ContentNode/PlaylistContentNode.bs b/playlet-lib/src/components/ContentNode/PlaylistContentNode.bs new file mode 100644 index 00000000..aee5ccb1 --- /dev/null +++ b/playlet-lib/src/components/ContentNode/PlaylistContentNode.bs @@ -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 diff --git a/playlet-lib/src/components/ContentNode/PlaylistContentNode.xml b/playlet-lib/src/components/ContentNode/PlaylistContentNode.xml index e26a5124..eb1904a6 100644 --- a/playlet-lib/src/components/ContentNode/PlaylistContentNode.xml +++ b/playlet-lib/src/components/ContentNode/PlaylistContentNode.xml @@ -1,5 +1,8 @@ + + + diff --git a/playlet-lib/src/components/ContentNode/PlaylistContentTask.bs b/playlet-lib/src/components/ContentNode/PlaylistContentTask.bs new file mode 100644 index 00000000..4225bd8e --- /dev/null +++ b/playlet-lib/src/components/ContentNode/PlaylistContentTask.bs @@ -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 diff --git a/playlet-lib/src/components/ContentNode/VideoContentNode.xml b/playlet-lib/src/components/ContentNode/VideoContentNode.xml index fe82985b..6789223c 100644 --- a/playlet-lib/src/components/ContentNode/VideoContentNode.xml +++ b/playlet-lib/src/components/ContentNode/VideoContentNode.xml @@ -5,8 +5,11 @@ + + - + + diff --git a/playlet-lib/src/components/ContextMenu/ContextMenuUtils.bs b/playlet-lib/src/components/ContextMenu/ContextMenuUtils.bs index 26c7eb33..79fbd4c3 100644 --- a/playlet-lib/src/components/ContextMenu/ContextMenuUtils.bs +++ b/playlet-lib/src/components/ContextMenu/ContextMenuUtils.bs @@ -31,7 +31,7 @@ namespace ContextMenuUtils if item.type = "video" LogInfo("Opening context menu for video:", item.videoId) title = item.title - subtitle = item.author + subtitle = item._author thumbnail = item.thumbnail else if item.type = "playlist" LogInfo("Opening context menu for playlist:", item.playlistId) diff --git a/playlet-lib/src/components/EcpArgs.bs b/playlet-lib/src/components/EcpArgs.bs index cbb898ba..a914553b 100644 --- a/playlet-lib/src/components/EcpArgs.bs +++ b/playlet-lib/src/components/EcpArgs.bs @@ -1,10 +1,9 @@ -import "pkg:/components/VideoPlayer/VideoUtils.bs" import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/Types.bs" function InitEcpArgs() - m.playQueue = m.top.findNode("PlayQueue") + m.videoQueue = m.top.findNode("VideoQueue") LaunchArgumentsReceived() m.scene.ObserveField("inputArgs", FuncName(InputArgumentsReceived)) @@ -46,6 +45,6 @@ function ProcessArguments(args as object) as void if args.timestamp <> invalid node.timestamp = args.timestamp end if - m.playQueue@.Play(node, -1) + m.videoQueue.playVideo = node end if end function diff --git a/playlet-lib/src/components/MainScene.bs b/playlet-lib/src/components/MainScene.bs index e1381794..c49731db 100644 --- a/playlet-lib/src/components/MainScene.bs +++ b/playlet-lib/src/components/MainScene.bs @@ -21,6 +21,12 @@ function MainSceneContainerChanged() end function function StartWebServer() + m.loungeService = m.top.findNode("LoungeService") + m.loungeService@.StartService() + m.webServer = m.top.findNode("WebServer") m.webServer@.StartServer() + + m.dialServer = m.top.findNode("DialServer") + m.dialServer@.StartServer() end function diff --git a/playlet-lib/src/components/MainScene.transpiled.brs b/playlet-lib/src/components/MainScene.transpiled.brs index e9b077b7..3cf9c0f9 100644 --- a/playlet-lib/src/components/MainScene.transpiled.brs +++ b/playlet-lib/src/components/MainScene.transpiled.brs @@ -22,7 +22,11 @@ function MainSceneContainerChanged() end function function StartWebServer() + m.loungeService = m.top.findNode("LoungeService") + m.loungeService.callfunc("StartService", invalid) m.webServer = m.top.findNode("WebServer") m.webServer.callfunc("StartServer", invalid) + m.dialServer = m.top.findNode("DialServer") + m.dialServer.callfunc("StartServer", invalid) end function '//# sourceMappingURL=./MainScene.brs.map \ No newline at end of file diff --git a/playlet-lib/src/components/MainScene.transpiled.xml b/playlet-lib/src/components/MainScene.transpiled.xml index be0af11e..435af8f6 100644 --- a/playlet-lib/src/components/MainScene.transpiled.xml +++ b/playlet-lib/src/components/MainScene.transpiled.xml @@ -16,9 +16,6 @@