Disable shorts (#620)

* Disable shorts

* Rename setting

* changelog
This commit is contained in:
Brahim Hadriche authored and GitHub committed 2025-05-22 22:13:44 -04:00
1 parent 6d9117a2a0
commit eb67d9e4c0
10 files changed
+200 -47

No files matched your search

+4 -1
View File
@@ -7,7 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
- Nothing worth mentioning yet. ### Added
- New settings category: `Content Feed`
- New setting: `Disable Shorts`
## [0.38.2] - 2025-05-22 ## [0.38.2] - 2025-05-22
@@ -101,9 +101,16 @@ function CreateChannelFeeds(authorId as string, author as string, tabs as object
return invalid return invalid
end if end if
disableShorts = m.preferences["content_feed.disable_shorts"]
feeds = [] feeds = []
for i = 0 to tabs.count() - 1 for i = 0 to tabs.count() - 1
tabName = tabs[i] tabName = tabs[i]
if tabName = "shorts" and disableShorts
LogInfo(`Skipping "Shorts" tab based on user settings`)
continue for
end if
if m.tabs.DoesExist(tabName) if m.tabs.DoesExist(tabName)
if tabsParams <> invalid and tabsParams.DoesExist(tabName) if tabsParams <> invalid and tabsParams.DoesExist(tabName)
params = tabsParams[tabName] params = tabsParams[tabName]
@@ -5,6 +5,7 @@
<field id="isSubscribed" type="boolean" onChange="OnSubscriptionChanged" /> <field id="isSubscribed" type="boolean" onChange="OnSubscriptionChanged" />
<field id="appController" type="node" bind="/AppController" /> <field id="appController" type="node" bind="/AppController" />
<field id="invidious" type="node" bind="/Invidious" /> <field id="invidious" type="node" bind="/Invidious" />
<field id="preferences" type="node" bind="/Preferences" />
<field id="bookmarksService" type="node" bind="/BookmarksService" /> <field id="bookmarksService" type="node" bind="/BookmarksService" />
<function name="ShowSortDialog" /> <function name="ShowSortDialog" />
</interface> </interface>
@@ -182,32 +182,13 @@ namespace InnertubeService
end function end function
function Search(query as string, options = invalid as object) as object function Search(query as string, options = invalid as object) as object
searchFilters = invalid return Innertube.Search(query, options)
continuation = ""
cancellation = invalid
raw = false
if options <> invalid
if options.DoesExist("searchFilters")
searchFilters = options.searchFilters
end if
if options.DoesExist("continuation")
continuation = options.continuation
end if
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if
if options.DoesExist("raw")
raw = options.raw
end if
end if
return Innertube.Search(query, searchFilters, continuation, cancellation, raw)
end function end function
function GetTrending(options = invalid as object) as object function GetTrending(options = invalid as object) as object
cancellation = invalid cancellation = invalid
params = "" params = ""
disableShorts = false
raw = false raw = false
if options <> invalid if options <> invalid
@@ -228,6 +209,9 @@ namespace InnertubeService
params = "4gIKGgh0cmFpbGVycw%3D%3D" params = "4gIKGgh0cmFpbGVycw%3D%3D"
end if end if
end if end if
if options.DoesExist("disableShorts")
disableShorts = options.disableShorts
end if
if options.DoesExist("raw") if options.DoesExist("raw")
raw = options.raw raw = options.raw
end if end if
@@ -252,7 +236,10 @@ namespace InnertubeService
return response.Json() return response.Json()
end if end if
feeds = Innertube.ParseResponseDataForFeeds(response.Json(), { skipCreatorOnTheRise: true }) feeds = Innertube.ParseResponseDataForFeeds(response.Json(), {
disableCreatorOnTheRise: true
disableShorts: disableShorts
})
result = { result = {
feeds: feeds feeds: feeds
@@ -286,6 +273,7 @@ namespace InnertubeService
cancellation = invalid cancellation = invalid
accessToken = invalid accessToken = invalid
continuation = "" continuation = ""
disableShorts = false
if options <> invalid if options <> invalid
if options.DoesExist("cancellation") if options.DoesExist("cancellation")
@@ -297,6 +285,9 @@ namespace InnertubeService
if options.DoesExist("continuation") if options.DoesExist("continuation")
continuation = options.continuation continuation = options.continuation
end if end if
if options.DoesExist("disableShorts")
disableShorts = options.disableShorts
end if
end if end if
request = Innertube.CreateBrowseRequest(browserId, Innertube.ClientType.Tv, "", continuation) request = Innertube.CreateBrowseRequest(browserId, Innertube.ClientType.Tv, "", continuation)
@@ -312,7 +303,7 @@ namespace InnertubeService
} }
end if end if
feeds = Innertube.ParseResponseDataForFeeds(response.Json()) feeds = Innertube.ParseResponseDataForFeeds(response.Json(), { disableShorts: disableShorts })
result = { result = {
feeds: feeds feeds: feeds
@@ -156,13 +156,13 @@ namespace Innertube
end function end function
function ParseShelfRenderer(nodeData as object, context as object) as object function ParseShelfRenderer(nodeData as object, context as object) as object
if context.skipCreatorOnTheRise = true if context.disableCreatorOnTheRise = true
badges = nodeData["badges"] badges = nodeData["badges"]
if IsArray(badges) if IsArray(badges)
for each badge in badges for each badge in badges
if ValidString(ObjectUtils.Dig(badge, ["metadataBadgeRenderer", "style"])) = "BADGE_STYLE_TYPE_FEATURED" if ValidString(ObjectUtils.Dig(badge, ["metadataBadgeRenderer", "style"])) = "BADGE_STYLE_TYPE_FEATURED"
label = ParseText(ObjectUtils.Dig(badge, ["metadataBadgeRenderer", "label"])) label = ParseText(ObjectUtils.Dig(badge, ["metadataBadgeRenderer", "label"]))
LogInfo(`Skipping 'Create on the Rise' shelf (${label})`) LogInfo(`Skipping 'Creator on the Rise' shelf (${label})`)
return invalid return invalid
end if end if
end for end for
@@ -179,7 +179,11 @@ namespace Innertube
return nodeData["contents"] return nodeData["contents"]
end function end function
function ParseReelShelfRenderer(nodeData as object, _context as object) as object function ParseReelShelfRenderer(nodeData as object, context as object) as object
if context.disableShorts = true
LogInfo("Skipping ReelShelfRenderer based on user settings")
return invalid
end if
' TODO: handle reelShelfRenderer.title ' TODO: handle reelShelfRenderer.title
return nodeData["items"] return nodeData["items"]
end function end function
@@ -276,20 +280,33 @@ namespace Innertube
end if end if
end if end if
liveNow = ValidString(ObjectUtils.Dig(nodeData, ["badges", 0, "metadataBadgeRenderer", "icon", "iconType"])) = "LIVE" isUpcoming = false
if not liveNow liveNow = false
thumbnailOverlays = nodeData["thumbnailOverlays"]
if IsArray(thumbnailOverlays) thumbnailOverlays = nodeData["thumbnailOverlays"]
for each overlay in thumbnailOverlays if IsArray(thumbnailOverlays)
if ValidString(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "style"])) = "LIVE" for each overlay in thumbnailOverlays
liveNow = true parsedTimeStatusRenderer = ParseThumbnailOverlayTimeStatusRenderer(overlay)
exit for if parsedTimeStatusRenderer = invalid
continue for
end if
if parsedTimeStatusRenderer.isShort
if context.disableShorts = true
LogInfo("Skipping Short based on user settings")
return invalid
end if end if
end for end if
end if
liveNow = liveNow or parsedTimeStatusRenderer.isLive
isUpcoming = isUpcoming or parsedTimeStatusRenderer.isUpcoming
end for
end if
if ValidString(ObjectUtils.Dig(nodeData, ["badges", 0, "metadataBadgeRenderer", "icon", "iconType"])) = "LIVE"
liveNow = true
end if end if
isUpcoming = false
premiereTimestamp = ObjectUtils.Dig(nodeData, ["upcomingEventData", "startTime"]) premiereTimestamp = ObjectUtils.Dig(nodeData, ["upcomingEventData", "startTime"])
if IsString(premiereTimestamp) if IsString(premiereTimestamp)
premiereTimestamp = premiereTimestamp.ToInt() premiereTimestamp = premiereTimestamp.ToInt()
@@ -362,7 +379,11 @@ namespace Innertube
thumbnailOverlays = nodeData["thumbnailOverlays"] thumbnailOverlays = nodeData["thumbnailOverlays"]
if IsArray(thumbnailOverlays) if IsArray(thumbnailOverlays)
for each overlay in thumbnailOverlays for each overlay in thumbnailOverlays
lengthText = ParseText(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "text"])) parsedTimeStatusRenderer = ParseThumbnailOverlayTimeStatusRenderer(overlay)
if parsedTimeStatusRenderer = invalid
continue for
end if
lengthText = parsedTimeStatusRenderer.text
if lengthText <> "" if lengthText <> ""
exit for exit for
end if end if
@@ -518,8 +539,20 @@ namespace Innertube
thumbnailOverlays = nodeData["thumbnailOverlays"] thumbnailOverlays = nodeData["thumbnailOverlays"]
if IsArray(thumbnailOverlays) if IsArray(thumbnailOverlays)
for each overlay in thumbnailOverlays for each overlay in thumbnailOverlays
liveNow = liveNow or (ValidString(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "style"])) = "LIVE") parsedTimeStatusRenderer = ParseThumbnailOverlayTimeStatusRenderer(overlay)
isUpcoming = isUpcoming or (ValidString(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "style"])) = "UPCOMING") if parsedTimeStatusRenderer = invalid
continue for
end if
if parsedTimeStatusRenderer.isShort
if context.disableShorts = true
LogInfo("Skipping Short based on user settings")
return invalid
end if
end if
liveNow = liveNow or parsedTimeStatusRenderer.isLive
isUpcoming = isUpcoming or parsedTimeStatusRenderer.isUpcoming
end for end for
end if end if
@@ -869,6 +902,11 @@ namespace Innertube
end function end function
function ParseShortsLockupViewModel(nodeData as object, context as object) as object function ParseShortsLockupViewModel(nodeData as object, context as object) as object
if context.disableShorts = true
LogInfo("Skipping Short based on user settings")
return invalid
end if
videoId = ObjectUtils.Dig(nodeData, ["onTap", "innertubeCommand", "reelWatchEndpoint", "videoId"]) videoId = ObjectUtils.Dig(nodeData, ["onTap", "innertubeCommand", "reelWatchEndpoint", "videoId"])
if not IsString(videoId) if not IsString(videoId)
LogWarn("Invalid video ID", nodeData) LogWarn("Invalid video ID", nodeData)
@@ -978,17 +1016,32 @@ namespace Innertube
thumbnailOverlays = ObjectUtils.Dig(nodeData, ["header", "tileHeaderRenderer", "thumbnailOverlays"]) thumbnailOverlays = ObjectUtils.Dig(nodeData, ["header", "tileHeaderRenderer", "thumbnailOverlays"])
if IsArray(thumbnailOverlays) if IsArray(thumbnailOverlays)
for each overlay in thumbnailOverlays for each overlay in thumbnailOverlays
maybeLengthText = ParseText(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "text"])) parsedTimeStatusRenderer = ParseThumbnailOverlayTimeStatusRenderer(overlay)
if parsedTimeStatusRenderer = invalid
continue for
end if
if parsedTimeStatusRenderer.isShort
if context.disableShorts = true
LogInfo("Skipping Short based on user settings")
return invalid
end if
end if
maybeLengthText = parsedTimeStatusRenderer.text
if maybeLengthText <> "" if maybeLengthText <> ""
lengthText = maybeLengthText lengthText = maybeLengthText
end if end if
liveNow = liveNow or parsedTimeStatusRenderer.isLive
isUpcoming = isUpcoming or parsedTimeStatusRenderer.isUpcoming
maybePercentDurationWatched = ObjectUtils.Dig(overlay, ["thumbnailOverlayResumePlaybackRenderer", "percentDurationWatched"]) maybePercentDurationWatched = ObjectUtils.Dig(overlay, ["thumbnailOverlayResumePlaybackRenderer", "percentDurationWatched"])
if maybePercentDurationWatched <> invalid if maybePercentDurationWatched <> invalid
percentDurationWatched = maybePercentDurationWatched percentDurationWatched = maybePercentDurationWatched
end if end if
liveNow = liveNow or (ValidString(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "style"])) = "LIVE")
isUpcoming = isUpcoming or (ValidString(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "style"])) = "UPCOMING")
end for end for
if liveNow or isUpcoming if liveNow or isUpcoming
lengthText = "" lengthText = ""
end if end if
@@ -1022,6 +1075,11 @@ namespace Innertube
end function end function
function TileRendererTypeShorts(nodeData as object, context as object) as object function TileRendererTypeShorts(nodeData as object, context as object) as object
if context.disableShorts = true
LogInfo("Skipping Short based on user settings")
return invalid
end if
videoId = nodeData["contentId"] videoId = nodeData["contentId"]
if not IsString(videoId) if not IsString(videoId)
LogWarn("Invalid video ID", nodeData) LogWarn("Invalid video ID", nodeData)
@@ -1204,6 +1262,34 @@ namespace Innertube
return ParseText(data["text"]) return ParseText(data["text"])
end function end function
function ParseThumbnailOverlayTimeStatusRenderer(data as object) as object
if data = invalid
return invalid
end if
if not IsAssociativeArray(data) or not data.DoesExist("thumbnailOverlayTimeStatusRenderer")
return invalid
end if
renderer = data["thumbnailOverlayTimeStatusRenderer"]
if not IsAssociativeArray(renderer)
return invalid
end if
text = ParseText(renderer["text"])
overlayStyle = ValidString(renderer["style"])
isLive = overlayStyle = "LIVE"
isUpcoming = overlayStyle = "UPCOMING"
isShort = overlayStyle = "SHORTS"
return {
"text": text
"isLive": isLive
"isUpcoming": isUpcoming
"isShort": isShort
}
end function
function StartNewFeed(title as string, context as object) as void function StartNewFeed(title as string, context as object) as void
if context.currentFeed <> invalid if context.currentFeed <> invalid
if context.currentFeed.items.Count() = 0 and context.currentFeed.title = "" if context.currentFeed.items.Count() = 0 and context.currentFeed.title = ""
@@ -6,7 +6,31 @@ import "pkg:/source/utils/Types.bs"
namespace Innertube namespace Innertube
function Search(query as string, searchFilters as object, continuation = "" as string, cancellation = invalid as object, raw = false as boolean) as object function Search(query as string, options = invalid as object) as object
searchFilters = invalid
continuation = ""
cancellation = invalid
disableShorts = false
raw = false
if options <> invalid
if options.DoesExist("searchFilters")
searchFilters = options.searchFilters
end if
if options.DoesExist("continuation")
continuation = options.continuation
end if
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if
if options.DoesExist("disableShorts")
disableShorts = options.disableShorts
end if
if options.DoesExist("raw")
raw = options.raw
end if
end if
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
payload = { payload = {
@@ -51,7 +75,7 @@ namespace Innertube
return response.Json() return response.Json()
end if end if
feeds = ParseResponseDataForFeeds(response.Json()) feeds = ParseResponseDataForFeeds(response.Json(), { disableShorts: disableShorts })
result = { result = {
feeds: feeds feeds: feeds
@@ -8,7 +8,9 @@ namespace Http
function new(server as object) function new(server as object)
super() super()
m.innertube = server.task.innertube task = server.task
m.innertube = task.innertube
m.preferences = task.preferences
end function end function
@get("/playlet-invidious-backend/authorize_token") @get("/playlet-invidious-backend/authorize_token")
@@ -65,6 +67,7 @@ namespace Http
options = { options = {
"accessToken": accessToken.Mid("Bearer ".Len()) "accessToken": accessToken.Mid("Bearer ".Len())
"disableShorts": m.preferences["content_feed.disable_shorts"]
} }
continuation = request.query.continuation continuation = request.query.continuation
if not StringUtils.IsNullOrEmpty(continuation) if not StringUtils.IsNullOrEmpty(continuation)
@@ -247,6 +250,7 @@ namespace Http
raw = request.query.raw <> invalid raw = request.query.raw <> invalid
options = { options = {
"disableShorts": m.preferences["content_feed.disable_shorts"]
raw: raw raw: raw
type: request.query.type type: request.query.type
} }
@@ -295,6 +299,7 @@ namespace Http
options = { options = {
"accessToken": accessToken.Mid("Bearer ".Len()) "accessToken": accessToken.Mid("Bearer ".Len())
"disableShorts": m.preferences["content_feed.disable_shorts"]
} }
continuation = request.query.continuation continuation = request.query.continuation
@@ -360,6 +365,7 @@ namespace Http
raw = request.query.raw <> invalid raw = request.query.raw <> invalid
options = { options = {
"disableShorts": m.preferences["content_feed.disable_shorts"]
raw: raw raw: raw
} }
+14
View File
@@ -53,6 +53,20 @@
}, },
], ],
}, },
{
displayText: "Content Feed",
key: "content_feed",
description: "Feed preferences",
children: [
{
displayText: "Disable Shorts",
key: "content_feed.disable_shorts",
description: "Disable short videos.",
type: "boolean",
defaultValue: false,
},
],
},
{ {
displayText: "Invidious", displayText: "Invidious",
key: "invidious", key: "invidious",
@@ -768,6 +768,22 @@
<source>The backend used for browsing and playing videos.</source> <source>The backend used for browsing and playing videos.</source>
<translation>The backend used for browsing and playing videos.</translation> <translation>The backend used for browsing and playing videos.</translation>
</message> </message>
<message>
<source>Content Feed</source>
<translation>Content Feed</translation>
</message>
<message>
<source>Feed preferences</source>
<translation>Feed preferences</translation>
</message>
<message>
<source>Disable Shorts</source>
<translation>Disable Shorts</translation>
</message>
<message>
<source>Disable short videos.</source>
<translation>Disable short videos.</translation>
</message>
<message> <message>
<source>Invidious preferences</source> <source>Invidious preferences</source>
<translation>Invidious preferences</translation> <translation>Invidious preferences</translation>
+5
View File
@@ -250,6 +250,11 @@ namespace Locale
SelectedBackend = "Selected backend" SelectedBackend = "Selected backend"
SelectedBackendDescription = "The backend used for browsing and playing videos." SelectedBackendDescription = "The backend used for browsing and playing videos."
ContentFeed = "Content Feed"
ContentPreferences = "Feed preferences"
DisableShorts = "Disable Shorts"
DisableShortsDescription = "Disable short videos."
' "Invidious" is used as node id, so we can't use it before refactoring node ids. ' "Invidious" is used as node id, so we can't use it before refactoring node ids.
' Either way, Invidious doesn't translate, so it's fine to skip it here ' Either way, Invidious doesn't translate, so it's fine to skip it here
' Invidious = "Invidious" ' Invidious = "Invidious"