Add trending back (Gaming and Live)
This commit is contained in:
1 parent
fbb4a45ce5
commit
38bfa1a102
15 files changed
+200
-1
No files matched your search
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Trending back (Gaming and Live) for Playlet backend and Invidious - to avoid a blank home screen when not logged in.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Retry condition issue in http client
|
- Retry condition issue in http client
|
||||||
|
|||||||
@@ -307,6 +307,58 @@ namespace InnertubeService
|
|||||||
return Innertube.Search(query, options)
|
return Innertube.Search(query, options)
|
||||||
end function
|
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
|
function GetHome(options = invalid as object) as object
|
||||||
return GetBrowseAuthenticatedPage("FEwhat_to_watch", options)
|
return GetBrowseAuthenticatedPage("FEwhat_to_watch", options)
|
||||||
end function
|
end function
|
||||||
|
|||||||
@@ -188,6 +188,16 @@ function MigrateExistingPreferences(userPrefs as object) as boolean
|
|||||||
isDirty = true
|
isDirty = true
|
||||||
end if
|
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)
|
' TODO:P2 handle case where saved preferences version is higher than current version (e.g. user downgraded)
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
user prefs saved need to be migrated. If the version is less than the
|
user prefs saved need to be migrated. If the version is less than the
|
||||||
current version, a migration is needed.
|
current version, a migration is needed.
|
||||||
-->
|
-->
|
||||||
<field id="__version" type="integer" value="7" />
|
<field id="__version" type="integer" value="8" />
|
||||||
<field id="prefsModel" type="array" />
|
<field id="prefsModel" type="array" />
|
||||||
<field id="preferenceFields" type="assocarray" />
|
<field id="preferenceFields" type="assocarray" />
|
||||||
<function name="GetUserPreferences" />
|
<function name="GetUserPreferences" />
|
||||||
|
|||||||
+42
@@ -237,6 +237,48 @@ namespace Http
|
|||||||
return true
|
return true
|
||||||
end function
|
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")
|
@get("/playlet-invidious-backend/api/v1/popular")
|
||||||
function GetPopular(context as object) as boolean
|
function GetPopular(context as object) as boolean
|
||||||
request = context.request
|
request = context.request
|
||||||
|
|||||||
@@ -14,6 +14,26 @@
|
|||||||
apiType: Invidious
|
apiType: Invidious
|
||||||
endpoint: auth_recommended
|
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
|
- title: Popular
|
||||||
id: popular
|
id: popular
|
||||||
feedSources:
|
feedSources:
|
||||||
|
|||||||
@@ -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:
|
popular:
|
||||||
title: Popular
|
title: Popular
|
||||||
url: /api/v1/popular
|
url: /api/v1/popular
|
||||||
|
|||||||
@@ -253,6 +253,14 @@
|
|||||||
id: "recommended",
|
id: "recommended",
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "trending_livestreams",
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "trending_gaming",
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: "popular",
|
id: "popular",
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
|||||||
@@ -312,6 +312,14 @@
|
|||||||
<source>Watch history</source>
|
<source>Watch history</source>
|
||||||
<translation>Wiedergabeverlauf</translation>
|
<translation>Wiedergabeverlauf</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Trending - Live</source>
|
||||||
|
<translation>Trends - Live</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Trending - Gaming</source>
|
||||||
|
<translation>Trends - Gaming</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Popular</source>
|
<source>Popular</source>
|
||||||
<translation>Populär</translation>
|
<translation>Populär</translation>
|
||||||
|
|||||||
@@ -88,6 +88,14 @@
|
|||||||
<source>Watch history</source>
|
<source>Watch history</source>
|
||||||
<translation>Watch history</translation>
|
<translation>Watch history</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Trending - Live</source>
|
||||||
|
<translation>Trending - Live</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Trending - Gaming</source>
|
||||||
|
<translation>Trending - Gaming</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Popular</source>
|
<source>Popular</source>
|
||||||
<translation>Popular</translation>
|
<translation>Popular</translation>
|
||||||
|
|||||||
@@ -80,6 +80,14 @@
|
|||||||
<source>Watch history</source>
|
<source>Watch history</source>
|
||||||
<translation>Ver el historial</translation>
|
<translation>Ver el historial</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Trending - Live</source>
|
||||||
|
<translation>Tendencias - En directo</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Trending - Gaming</source>
|
||||||
|
<translation>Tendencias - Juegos</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Popular</source>
|
<source>Popular</source>
|
||||||
<translation>Popular</translation>
|
<translation>Popular</translation>
|
||||||
|
|||||||
@@ -308,6 +308,14 @@
|
|||||||
<source>Test instance</source>
|
<source>Test instance</source>
|
||||||
<translation>Probar Instancia</translation>
|
<translation>Probar Instancia</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Trending - Live</source>
|
||||||
|
<translation>Tendencias - En vivo</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Trending - Gaming</source>
|
||||||
|
<translation>Tendencias - Videojuegos</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Popular</source>
|
<source>Popular</source>
|
||||||
<translation>Popular</translation>
|
<translation>Popular</translation>
|
||||||
|
|||||||
@@ -76,6 +76,14 @@
|
|||||||
<source>Watch history</source>
|
<source>Watch history</source>
|
||||||
<translation>Historique</translation>
|
<translation>Historique</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Trending - Live</source>
|
||||||
|
<translation>Tendances - En direct</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Trending - Gaming</source>
|
||||||
|
<translation>Tendances - Jeux vidéo</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Popular</source>
|
<source>Popular</source>
|
||||||
<translation>Populaire</translation>
|
<translation>Populaire</translation>
|
||||||
|
|||||||
@@ -140,6 +140,14 @@
|
|||||||
<source>Watch history</source>
|
<source>Watch history</source>
|
||||||
<translation>Histórico de assistidos</translation>
|
<translation>Histórico de assistidos</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Trending - Live</source>
|
||||||
|
<translation>Em alta - Ao vivo</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Trending - Gaming</source>
|
||||||
|
<translation>Em alta - Jogos</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Popular</source>
|
<source>Popular</source>
|
||||||
<translation>Popular</translation>
|
<translation>Popular</translation>
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ namespace Locale
|
|||||||
Recommended = "Recommended"
|
Recommended = "Recommended"
|
||||||
Playlists = "Playlists"
|
Playlists = "Playlists"
|
||||||
WatchHistory = "Watch history"
|
WatchHistory = "Watch history"
|
||||||
|
TrendingLive = "Trending - Live"
|
||||||
|
TrendingGaming = "Trending - Gaming"
|
||||||
Popular = "Popular"
|
Popular = "Popular"
|
||||||
Videos = "Videos"
|
Videos = "Videos"
|
||||||
Shorts = "Shorts"
|
Shorts = "Shorts"
|
||||||
|
|||||||
Reference in new issue
Block a user