diff --git a/CHANGELOG.md b/CHANGELOG.md
index b54072b8..203f1810 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Added
+
+- Trending back (Gaming and Live) for Playlet backend and Invidious - to avoid a blank home screen when not logged in.
+
### Fixed
- Retry condition issue in http client
diff --git a/playlet-lib/src/components/Services/Innertube/InnertubeService.bs b/playlet-lib/src/components/Services/Innertube/InnertubeService.bs
index cbd660e0..9f7355d8 100644
--- a/playlet-lib/src/components/Services/Innertube/InnertubeService.bs
+++ b/playlet-lib/src/components/Services/Innertube/InnertubeService.bs
@@ -307,6 +307,58 @@ namespace InnertubeService
return Innertube.Search(query, options)
end function
+ function GetTrending(options = invalid as object) as object
+ cancellation = OptionUtils.Get(options, "cancellation")
+ trendingType = LCase(OptionUtils.GetOrDefault(options, "type", ""))
+ disableShorts = OptionUtils.GetOrDefault(options, "disableShorts", false)
+ raw = OptionUtils.GetOrDefault(options, "raw", false)
+
+ if trendingType = "gaming"
+ browseId = "UCOpNcN46UbXVtpKMrmU4Abg" ' Gaming
+ params = "Egh0cmVuZGluZw%3D%3D"
+ else
+ browseId = "UC4R8DWoMoI7CAwX8_LjQHig" ' Livestreams (default)
+ params = "EgdsaXZldGFikgEDCKEK"
+ end if
+
+ request = Innertube.CreateBrowseRequest(browseId, Innertube.ClientType.Web, { params: params })
+ request.Cancellation(cancellation)
+
+ if raw
+ request.LogCurlCommand(true)
+ request.NoCache()
+ end if
+
+ response = request.Await()
+ if not response.IsSuccess()
+ return {
+ error: response.ErrorMessage()
+ }
+ end if
+
+ if raw
+ return response.Json()
+ end if
+
+ feeds = Innertube.ParseResponseDataForFeeds(response.Json(), {
+ response: response
+ disableCreatorOnTheRise: true
+ disableShorts: disableShorts
+ browseId: browseId
+ })
+
+ result = {
+ feeds: feeds
+ }
+
+ cacheControl = Innertube.ParseResponseForCacheControl(response)
+ if cacheControl <> invalid
+ result["cache-control"] = cacheControl
+ end if
+
+ return result
+ end function
+
function GetHome(options = invalid as object) as object
return GetBrowseAuthenticatedPage("FEwhat_to_watch", options)
end function
diff --git a/playlet-lib/src/components/Services/Preferences/Preferences.bs b/playlet-lib/src/components/Services/Preferences/Preferences.bs
index 3571df6f..23d1b5d3 100644
--- a/playlet-lib/src/components/Services/Preferences/Preferences.bs
+++ b/playlet-lib/src/components/Services/Preferences/Preferences.bs
@@ -188,6 +188,16 @@ function MigrateExistingPreferences(userPrefs as object) as boolean
isDirty = true
end if
+ if userPrefs.__version = 7
+ homeScreenLayout = userPrefs["misc.home_screen_layout"]
+ if IsArray(homeScreenLayout)
+ homeScreenLayout.Push({ id: "trending_livestreams", enabled: true })
+ homeScreenLayout.Push({ id: "trending_gaming", enabled: true })
+ end if
+ userPrefs.__version = 8
+ isDirty = true
+ end if
+
' TODO:P2 handle case where saved preferences version is higher than current version (e.g. user downgraded)
#if DEBUG
diff --git a/playlet-lib/src/components/Services/Preferences/Preferences.xml b/playlet-lib/src/components/Services/Preferences/Preferences.xml
index 5194958d..48d70378 100644
--- a/playlet-lib/src/components/Services/Preferences/Preferences.xml
+++ b/playlet-lib/src/components/Services/Preferences/Preferences.xml
@@ -5,7 +5,7 @@
user prefs saved need to be migrated. If the version is less than the
current version, a migration is needed.
-->
-
+
diff --git a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PlayletInvidiousBackendRouter.bs b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PlayletInvidiousBackendRouter.bs
index a405cd87..b7e82469 100644
--- a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PlayletInvidiousBackendRouter.bs
+++ b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PlayletInvidiousBackendRouter.bs
@@ -237,6 +237,48 @@ namespace Http
return true
end function
+ @get("/playlet-invidious-backend/api/v1/trending")
+ function GetTrending(context as object) as boolean
+ request = context.request
+ response = context.response
+
+ raw = request.query.raw <> invalid
+
+ options = {
+ "disableShorts": m.preferences["content_feed.disable_shorts"]
+ raw: raw
+ type: request.query.type
+ }
+
+ result = InnertubeService.GetTrending(options)
+ if raw
+ response.Json(result)
+ return true
+ end if
+
+ if result.error <> invalid
+ response.Json(result)
+ response.http_code = 500
+ return true
+ end if
+
+ if not IsArray(result.feeds) or result.feeds.Count() = 0
+ response.Json({
+ "error": "Failed to get trending feed"
+ })
+ response.http_code = 500
+ return true
+ end if
+
+ response.Json(ValidArray(result.feeds[0].items))
+
+ if result.DoesExist("cache-control")
+ response.headers["cache-control"] = result["cache-control"]
+ end if
+
+ return true
+ end function
+
@get("/playlet-invidious-backend/api/v1/popular")
function GetPopular(context as object) as boolean
request = context.request
diff --git a/playlet-lib/src/config/default_home_layout.yaml b/playlet-lib/src/config/default_home_layout.yaml
index 2b601ef2..31625486 100644
--- a/playlet-lib/src/config/default_home_layout.yaml
+++ b/playlet-lib/src/config/default_home_layout.yaml
@@ -14,6 +14,26 @@
apiType: Invidious
endpoint: auth_recommended
+- title: Trending - Live
+ id: trending_livestreams
+ feedSources:
+ - id: inv_trending_livestreams
+ title: Trending - Live
+ apiType: Invidious
+ endpoint: trending
+ queryParams:
+ type: Livestreams
+
+- title: Trending - Gaming
+ id: trending_gaming
+ feedSources:
+ - id: inv_trending_gaming
+ title: Trending - Gaming
+ apiType: Invidious
+ endpoint: trending
+ queryParams:
+ type: Gaming
+
- title: Popular
id: popular
feedSources:
diff --git a/playlet-lib/src/config/invidious_video_api.yaml b/playlet-lib/src/config/invidious_video_api.yaml
index f21631b6..e53ef29e 100644
--- a/playlet-lib/src/config/invidious_video_api.yaml
+++ b/playlet-lib/src/config/invidious_video_api.yaml
@@ -1,3 +1,16 @@
+trending:
+ title: Trending
+ url: /api/v1/trending
+ cacheSeconds: 21600 # 6 hours
+ queryParams:
+ type:
+ type:
+ - Livestreams
+ - Gaming
+ region:
+ type: "#ISO3166"
+ default: GetUserCountryCode
+
popular:
title: Popular
url: /api/v1/popular
diff --git a/playlet-lib/src/config/preferences.json5 b/playlet-lib/src/config/preferences.json5
index b3f0c7f9..ee99d98d 100644
--- a/playlet-lib/src/config/preferences.json5
+++ b/playlet-lib/src/config/preferences.json5
@@ -253,6 +253,14 @@
id: "recommended",
enabled: true,
},
+ {
+ id: "trending_livestreams",
+ enabled: true,
+ },
+ {
+ id: "trending_gaming",
+ enabled: true,
+ },
{
id: "popular",
enabled: true,
diff --git a/playlet-lib/src/locale/de_DE/translations.ts b/playlet-lib/src/locale/de_DE/translations.ts
index 2c9bfff1..27e84e6a 100644
--- a/playlet-lib/src/locale/de_DE/translations.ts
+++ b/playlet-lib/src/locale/de_DE/translations.ts
@@ -312,6 +312,14 @@
Watch history
Wiedergabeverlauf
+
+ Trending - Live
+ Trends - Live
+
+
+ Trending - Gaming
+ Trends - Gaming
+
Popular
Populär
diff --git a/playlet-lib/src/locale/en_US/translations.ts b/playlet-lib/src/locale/en_US/translations.ts
index b3bb382a..0d37bdcb 100644
--- a/playlet-lib/src/locale/en_US/translations.ts
+++ b/playlet-lib/src/locale/en_US/translations.ts
@@ -88,6 +88,14 @@
Watch history
Watch history
+
+ Trending - Live
+ Trending - Live
+
+
+ Trending - Gaming
+ Trending - Gaming
+
Popular
Popular
diff --git a/playlet-lib/src/locale/es_ES/translations.ts b/playlet-lib/src/locale/es_ES/translations.ts
index fe4478f5..bf0cbe17 100644
--- a/playlet-lib/src/locale/es_ES/translations.ts
+++ b/playlet-lib/src/locale/es_ES/translations.ts
@@ -80,6 +80,14 @@
Watch history
Ver el historial
+
+ Trending - Live
+ Tendencias - En directo
+
+
+ Trending - Gaming
+ Tendencias - Juegos
+
Popular
Popular
diff --git a/playlet-lib/src/locale/es_MX/translations.ts b/playlet-lib/src/locale/es_MX/translations.ts
index 9f57ab48..fe0bc770 100644
--- a/playlet-lib/src/locale/es_MX/translations.ts
+++ b/playlet-lib/src/locale/es_MX/translations.ts
@@ -308,6 +308,14 @@
Test instance
Probar Instancia
+
+ Trending - Live
+ Tendencias - En vivo
+
+
+ Trending - Gaming
+ Tendencias - Videojuegos
+
Popular
Popular
diff --git a/playlet-lib/src/locale/fr_CA/translations.ts b/playlet-lib/src/locale/fr_CA/translations.ts
index 9a9b67ad..fd4ed6c7 100644
--- a/playlet-lib/src/locale/fr_CA/translations.ts
+++ b/playlet-lib/src/locale/fr_CA/translations.ts
@@ -76,6 +76,14 @@
Watch history
Historique
+
+ Trending - Live
+ Tendances - En direct
+
+
+ Trending - Gaming
+ Tendances - Jeux vidéo
+
Popular
Populaire
diff --git a/playlet-lib/src/locale/pt_BR/translations.ts b/playlet-lib/src/locale/pt_BR/translations.ts
index 996fa8a3..b90ad90c 100644
--- a/playlet-lib/src/locale/pt_BR/translations.ts
+++ b/playlet-lib/src/locale/pt_BR/translations.ts
@@ -140,6 +140,14 @@
Watch history
Histórico de assistidos
+
+ Trending - Live
+ Em alta - Ao vivo
+
+
+ Trending - Gaming
+ Em alta - Jogos
+
Popular
Popular
diff --git a/playlet-lib/src/source/utils/Locale.bs b/playlet-lib/src/source/utils/Locale.bs
index f0295c14..4f03daec 100644
--- a/playlet-lib/src/source/utils/Locale.bs
+++ b/playlet-lib/src/source/utils/Locale.bs
@@ -41,6 +41,8 @@ namespace Locale
Recommended = "Recommended"
Playlists = "Playlists"
WatchHistory = "Watch history"
+ TrendingLive = "Trending - Live"
+ TrendingGaming = "Trending - Gaming"
Popular = "Popular"
Videos = "Videos"
Shorts = "Shorts"