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

[Test] Channels feed #346

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
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="[164,36]">

<ContentNode role="content" />
</CheckList>
Expand Down
31 changes: 31 additions & 0 deletions playlet-lib/src/components/Services/Invidious/InvidiousService.bs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,37 @@ namespace Invidious
}
end function

function AuthChannelsHandler(context as object) as object
response = context.response
authToken = context.authToken

m.DeleteExpiredToken(response, authToken)

if response.StatusCode() <> 200
return invalid
end if

json = response.Json()
if json = invalid
return invalid
end if

channels = []
for each item in json
channels.push({
"type": "channel"
"author": item.author
"authorId": item.authorId
})
end for

channels.SortBy("author")

return {
items: channels
}
end function

function WatchHistoryHandler(context as object) as object
response = context.response
authToken = context.authToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ namespace InvidiousContent

function GetChannelThumbnail(authorThumbnails as object) as string
if authorThumbnails = invalid or authorThumbnails.Count() = 0
return ""
return "pkg:/images/icons/user-200.png"
end if
url = authorThumbnails[authorThumbnails.Count() - 1].url
if url.startsWith("//")
Expand Down
57 changes: 41 additions & 16 deletions playlet-lib/src/components/Services/Preferences/Preferences.bs
Original file line number Diff line number Diff line change
Expand Up @@ -93,28 +93,53 @@ function MigrateExistingPreferences(userPrefs as object) as boolean
isDirty = false

' v0 -> v1
instances = RegistryUtils.Read(RegistryUtils.INVIDIOUS_INSTANCES)
if instances <> invalid
currentInstance = userPrefs["invidious.instance"]
if currentInstance = invalid or currentInstance = ""
instances = ParseJson(instances)
if instances.Count() > 0
instance = instances[0]
if instance <> invalid and instance <> ""
userPrefs["invidious.instance"] = instance
isDirty = true
if not userPrefs.DoesExist("__version")
instances = RegistryUtils.Read(RegistryUtils.INVIDIOUS_INSTANCES)
if instances <> invalid
currentInstance = userPrefs["invidious.instance"]
if currentInstance = invalid or currentInstance = ""
instances = ParseJson(instances)
if instances.Count() > 0
instance = instances[0]
if instance <> invalid and instance <> ""
userPrefs["invidious.instance"] = instance
end if
end if
end if
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_INSTANCES)
end if
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_INSTANCES)
end if

' v1 -> v2 goes here (if needed)
' if userPrefs.__version = 1
' 'do stuff
' end if
' v1 -> v2
if ValidInt(userPrefs.__version) = 1
if userPrefs.DoesExist("misc.home_screen_layout")
homeScreenLayout = userPrefs["misc.home_screen_layout"]
if IsArray(homeScreenLayout)
containsChannels = false
for each item in homeScreenLayout
if item.id = "channels"
containsChannels = true
exit for
end if
end for
if not containsChannels
' channels was added in v2, and should be the last item in the array
homeScreenLayout.push({
id: "channels"
enabled: false
})
userPrefs["misc.home_screen_layout"] = homeScreenLayout
end if
end if
end if
userPrefs.__version = 2
end if

if ValidInt(userPrefs.__version) <> m.top.__version
isDirty = true
end if

' TODO:PX handle case where saved preferences version is higher than current version (e.g. user downgraded)
' TODO:P2 handle case where saved preferences version is higher than current version (e.g. user downgraded)
return isDirty
end function

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
user prefs saved need to be migrated. If the version is less than the
current version, a migration is needed.
-->
<field id="__version" type="integer" value="1" />
<field id="__version" type="integer" value="2" />
<field id="prefsModel" type="array" />
<field id="preferenceFields" type="assocarray" />
<function name="GetUserPreferences" />
Expand Down
8 changes: 8 additions & 0 deletions playlet-lib/src/config/default_home_layout.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,11 @@
title: Watch history
apiType: Invidious
endpoint: watch_history

- title: Channels
id: channels
feedSources:
- id: inv_auth_channels
title: Channels
apiType: Invidious
endpoint: auth_channels
6 changes: 6 additions & 0 deletions playlet-lib/src/config/invidious_video_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ auth_playlists:
url: /api/v1/auth/playlists
authenticated: true

auth_channels:
title: Channels
url: /api/v1/auth/subscriptions
authenticated: true
responseHandler: AuthChannelsHandler

playlist:
title: Playlist
url: /api/v1/playlists/{plid}
Expand Down
6 changes: 6 additions & 0 deletions playlet-lib/src/config/preferences.json5
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@
id: "watch_history",
enabled: true,
},
{
// Channels currently disabled because we don't have any channel info
// except the id and name, so it doesn't look nice.
id: "channels",
enabled: false,
},
],
visibility: "tv",
rokuComponent: "EditHomeScreenControl",
Expand Down