Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continue watching #236

Draft
wants to merge 54 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
a6c92b7
Continue watching - planning
iBicha Dec 20, 2023
a5d6b6f
Continue watching
iBicha Dec 21, 2023
f7213e5
Lint fix
Dec 21, 2023
48f0939
TODO
iBicha Dec 21, 2023
d174f65
Continue watching as a paginated api
iBicha Dec 21, 2023
b0ac3d8
Lint fix
Dec 21, 2023
04b4df8
Watch history pagination proxying
iBicha Dec 21, 2023
542723f
Lint fix
Dec 21, 2023
1d696f9
Merge branch 'main' into feature/continue-watching
iBicha Dec 21, 2023
c30c0ab
Remove some fields from payload
iBicha Dec 21, 2023
de033a5
Handle removing video from watch later
iBicha Dec 22, 2023
9ca80d8
Merge branch 'main' into feature/continue-watching
iBicha Dec 22, 2023
662bfe0
max video cap
iBicha Dec 22, 2023
c72864f
Setting controls
iBicha Dec 22, 2023
bf147ef
control limits
iBicha Dec 22, 2023
6087013
Controls for web app
iBicha Dec 22, 2023
cf6faa9
Lint fix
Dec 22, 2023
7dcdecb
PlaylistViewCell progress bar
iBicha Dec 22, 2023
4517b19
Merge branch 'main' into feature/continue-watching
iBicha Dec 22, 2023
7b9bd88
Merge branch 'main' into feature/continue-watching
iBicha Dec 22, 2023
79027dd
Web app support
iBicha Dec 22, 2023
6372710
Update TODO
iBicha Dec 22, 2023
0cb70ce
remove comment
iBicha Dec 22, 2023
d2af560
Merge branch 'main' into feature/continue-watching
iBicha Dec 23, 2023
a95402e
Video player adds to continue watching only when enabled
iBicha Dec 23, 2023
ac38ae9
Merge branch 'main' into feature/continue-watching
iBicha Dec 23, 2023
565b995
Limit videos when loading and saving
iBicha Dec 23, 2023
446629a
Lint fix
Dec 23, 2023
dd1f90a
small tweak
iBicha Dec 23, 2023
e3140fe
Limit continue watching videos
iBicha Dec 25, 2023
75eae99
Lint fix
Dec 25, 2023
8d24535
Merge branch 'main' into feature/continue-watching
iBicha Dec 28, 2023
b6fba06
Merge branch 'main' into feature/continue-watching
iBicha Dec 31, 2023
1d8757c
TODO
iBicha Dec 31, 2023
8ca255f
Merge branch 'main' into feature/continue-watching
iBicha Jan 6, 2024
3a1941f
Merge branch 'main' into feature/continue-watching
iBicha Jan 6, 2024
83d8ea8
bump preferences version
iBicha Jan 7, 2024
0797dc7
Merge branch 'main' into feature/continue-watching
iBicha Jan 7, 2024
15ea377
Refactor for FeedContentNode
iBicha Jan 7, 2024
c1bb4a8
Merge branch 'main' into feature/continue-watching
iBicha Jan 9, 2024
3b6c03f
Fixes
iBicha Jan 9, 2024
bd86364
This is turning into garbage, I'll redo this
iBicha Jan 9, 2024
5d70c7a
Lint fix
Jan 9, 2024
62f0bba
Merge branch 'main' into feature/continue-watching
iBicha Jan 15, 2024
0c13c2b
http2 connection sharing
iBicha Jan 15, 2024
b35804b
Merge branch 'main' into feature/continue-watching
iBicha Jan 21, 2024
ac286e0
remove todo
iBicha Jan 21, 2024
ac9c659
move node
iBicha Jan 21, 2024
cb0e0c4
Merge branch 'main' into feature/continue-watching
iBicha Feb 5, 2024
fa7d493
Fix
iBicha Feb 5, 2024
a26a74b
no message
iBicha Feb 5, 2024
ef3eff5
Merge branch 'main' into feature/continue-watching
iBicha Feb 10, 2024
21fcb17
Lint fix
Feb 10, 2024
e4fe25f
Merge branch 'main' into feature/continue-watching
iBicha Feb 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions playlet-lib/src/components/ContentNode/FeedContentNode.bs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import "pkg:/components/VideoFeed/VideoRowCell/FeedContentNodeUtils.bs"
import "pkg:/source/utils/Types.bs"

function OnReactivity()
if m.reactivity <> invalid
for each item in m.reactivity
item.node.unobserveFieldScoped(item.field)
end for
end if

m.reactivity = m.top.reactivity
if m.reactivity <> invalid
for each item in m.reactivity
item.node.observeFieldScoped(item.field, FuncName(ResetNode))
end for
end if
end function

function ResetNode()
FeedContentNodeUtils.ResetSelf(m.top)
end function
1 change: 1 addition & 0 deletions playlet-lib/src/components/ContentNode/FeedContentNode.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<field id="feedSources" type="array" />
<field id="feedSourcesIndex" type="integer" />
<field id="loadState" type="string" />
<field id="reactivity" type="array" onChange="OnReactivity" />
</interface>
</component>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<field id="index" type="integer" value="-1" />
<!-- index in a feed -->
<field id="feedSourcesIndex" type="integer" value="-1" />
<field id="progressNode" type="node" />

<field id="author" type="string" />
<field id="authorId" type="string" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<component name="VideoProgressContentNode" extends="ContentNode">
<interface>
<field id="videoId" type="string" />
<!-- The date of watching the video as a unix timestamp -->
<field id="date" type="integer" />
<!-- The progress in seconds -->
<field id="timestamp" type="integer" />
<!-- The duration in seconds -->
<field id="duration" type="integer" />
</interface>
</component>
1 change: 1 addition & 0 deletions playlet-lib/src/components/MainScene.transpiled.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<Preferences id="Preferences" />
<Bookmarks id="Bookmarks" />
<SearchHistory id="SearchHistory" />
<ContinueWatching id="ContinueWatching" />
<Invidious id="Invidious" />
<PlayletWebServer id="WebServer" port="8888" />
</AppController>
Expand Down
8 changes: 6 additions & 2 deletions playlet-lib/src/components/MainScene.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@
<PlayQueue id="PlayQueue"
invidious="bind:../Invidious"
notifications="bind:../Notifications"
preferences="bind:../Preferences" />
preferences="bind:../Preferences"
continueWatching="bind:../ContinueWatching" />
<ApplicationInfo id="ApplicationInfo" />
<Preferences id="Preferences" />
<Bookmarks id="Bookmarks" />
<SearchHistory id="SearchHistory"
preferences="bind:../Preferences" />
<ContinueWatching id="ContinueWatching"
preferences="bind:../Preferences" />

<Invidious id="Invidious"
webServer="bind:../WebServer"
Expand All @@ -72,7 +75,8 @@
invidious="bind:../Invidious"
preferences="bind:../Preferences"
playQueue="bind:../PlayQueue"
bookmarks="bind:../Bookmarks" />
bookmarks="bind:../Bookmarks"
continueWatching="bind:../ContinueWatching" />
</AppController>
</children>
</component>
9 changes: 7 additions & 2 deletions playlet-lib/src/components/MainScene_bindings.transpiled.brs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ function InitializeBindings()
"PlayQueue": {
"invidious": "../Invidious",
"notifications": "../Notifications",
"preferences": "../Preferences"
"preferences": "../Preferences",
"continueWatching": "../ContinueWatching"
},
"SearchHistory": {
"preferences": "../Preferences"
},
"ContinueWatching": {
"preferences": "../Preferences"
},
"Invidious": {
"webServer": "../WebServer",
"applicationInfo": "../ApplicationInfo",
Expand All @@ -32,7 +36,8 @@ function InitializeBindings()
"invidious": "../Invidious",
"preferences": "../Preferences",
"playQueue": "../PlayQueue",
"bookmarks": "../Bookmarks"
"bookmarks": "../Bookmarks",
"continueWatching": "../ContinueWatching"
}
}
}
Expand Down
1 change: 1 addition & 0 deletions playlet-lib/src/components/PlayQueue/PlayQueue.bs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ function LoadPlaylist(playlist as object) as void
task = AsyncTask.Start(Tasks.PlaylistContentTask, {
content: playlist
invidious: m.top.invidious
continueWatchingContent: m.top.continueWatching.content
}, OnPlaylistContentTaskResult)
m.pendingLoadTasks[task.id] = task
end function
Expand Down
1 change: 1 addition & 0 deletions playlet-lib/src/components/PlayQueue/PlayQueue.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<field id="index" type="integer" value="-1" onChange="OnIndexChange" />
<field id="playlistIndex" type="integer" value="-1" />
<field id="invidious" type="node" />
<field id="continueWatching" type="node" />
<field id="notifications" type="node" />
<field id="preferences" type="node" />
<function name="Play" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
function PlaylistContentTask(input as object) as object
contentNode = input.content
invidiousNode = input.invidious
continueWatchingContent = input.continueWatchingContent

if m.top.cancel
contentNode.loadState = FeedLoadState.None
Expand Down Expand Up @@ -33,7 +34,7 @@ function PlaylistContentTask(input as object) as object
end if

instance = service.GetInstance()
InvidiousContent.ToPlaylistContentNode(contentNode, metadata, instance)
InvidiousContent.ToPlaylistContentNode(contentNode, metadata, instance, continueWatchingContent)

childCount = contentNode.getChildCount()
if metadata.videos.Count() > 0 or childCount < metadata.videoCount
Expand Down
1 change: 1 addition & 0 deletions playlet-lib/src/components/PlaylistView/PlaylistView.bs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ function LoadPlaylist() as void
m.playlistLoadTask = AsyncTask.Start(Tasks.PlaylistContentTask, {
content: m.top.content
invidious: m.top.invidious
continueWatchingContent: m.top.continueWatching.content
}, OnPlaylistContentTaskResult)
end function

Expand Down
1 change: 1 addition & 0 deletions playlet-lib/src/components/PlaylistView/PlaylistView.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<field id="invidious" type="node" bind="/Invidious" />
<field id="playQueue" type="node" bind="/PlayQueue" />
<field id="bookmarks" type="node" bind="/Bookmarks" />
<field id="continueWatching" type="node" bind="/ContinueWatching" />
<function name="OpenPlaylistChannel" />
</interface>
<children>
Expand Down
31 changes: 31 additions & 0 deletions playlet-lib/src/components/PlaylistView/PlaylistViewCell.bs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "pkg:/source/utils/Types.bs"
function Init()
m.durationRect = m.top.FindNode("durationRect")
m.durationLabel = m.top.FindNode("durationLabel")
m.progressRect = m.top.FindNode("progressRect")
end function

function OnContentSet() as void
Expand All @@ -23,6 +24,8 @@ function OnContentSet() as void
else
m.top.durationRectVisible = false
end if

SetupProgress(content)
end function

function SetDurationText(text as string) as void
Expand All @@ -41,3 +44,31 @@ function SetDurationText(text as string) as void
rect.width = size.width + 16
rect.translation = [rectParent.width - rect.width, rect.translation[1]]
end function

function SetupProgress(content as object)
if m.progressNode <> invalid
m.progressNode.unobserveFieldScoped("timestamp")
m.progressNode = invalid
end if

m.progressNode = content.progressNode
if m.progressNode <> invalid
m.progressNode.observeFieldScoped("timestamp", FuncName(SetProgress))
end if
SetProgress()
end function

function SetProgress() as void
if m.progressNode = invalid
m.progressRect.scale = [0, 1]
return
end if

duration = m.progressNode.duration
timestamp = m.progressNode.timestamp
progress = 0
if duration > 0
progress = timestamp / duration
end if
m.progressRect.scale = [progress, 1]
end function
8 changes: 7 additions & 1 deletion playlet-lib/src/components/PlaylistView/PlaylistViewCell.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@
font="font:SmallestSystemFont"
translation="[8, 0]" />
</Rectangle>

<Rectangle
id="progressRect"
width="190"
height="5"
color="0xFF0000"
translation="[0, 102]"
scale="[0.0, 1.0]" />
</Poster>

<LayoutGroup
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/components/Services/ContinueWatching/ContinueWatchingUtils.bs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/Types.bs"

function Init()
m.top.focusable = true
m.top.itemSpacings = [8]
m.button = m.top.findNode("Button")
m.button.observeField("buttonSelected", FuncName(OnButtonSelected))
end function

function OnFocusChange() as void
if not m.top.focus
return
end if
NodeSetFocus(m.button, true)
end function

function BindPreference(preferences as object, key as string)
' Do nothing
end function

function OnButtonSelected()
continueWatchingNode = m.top.getScene().findNode("ContinueWatching")
ContinueWatchingUtils.Clear(continueWatchingNode)
DialogUtils.ShowDialog("Continue watching cleared.", "Success")
end function
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<component name="ClearContinueWatchingControl" extends="LayoutGroup" includes="Focus">
<interface>
<field id="displayText" type="string" alias="Button.text" />
<field id="description" type="string" alias="DescriptionLabel.text" />
<function name="BindPreference" />
</interface>
<children>
<Button
id="Button"
minWidth="380"
showFocusFootprint="true" />
<Label id="DescriptionLabel"
width="450"
color="0xb4b4b4ff"
wrap="true">
<Font role="font" uri="font:SystemFontFile" size="18" />
</Label>
</children>
</component>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<CheckList
id="checkList"
vertFocusAnimationStyle="floatingFocus"
translation="[164,70]">
translation="[165,40]">

<ContentNode role="content" />
</CheckList>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ function CanFetchVideoThumbails(instance as string, testNode as object) as void
return
end if

contentNode = InvidiousContent.ToVideoContentNode(invalid, json, instance)
continueWatchingContentMock = CreateObject("roSGNode", "ContentNode")
contentNode = InvidiousContent.ToVideoContentNode(invalid, json, instance, continueWatchingContentMock)
thumbnail = contentNode.thumbnail
if StringUtils.IsNullOrEmpty(thumbnail)
testNode.state = "failed"
Expand Down
Loading
Loading