Compare commits

...
11 Commits
Author SHA1 Message Date
Brahim Hadriche 013e2f49ca Release v0.38.1 (#614) 2025-05-20 12:30:45 -04:00
Brahim Hadriche d2fbd59d6a Fix video does not continuing from previous progress when opened 2025-05-20 12:27:21 -04:00
Brahim Hadriche f681a7024c Fix history cache, show percent watched in web app 2025-05-19 18:56:07 -04:00
Brahim Hadriche e9c2ab9f76 Release v0.38.0 (#613) 2025-05-19 18:02:20 -04:00
Brahim Hadriche aed102f57a Fix a bug where watch history videos repeat indefinitely 2025-05-19 17:50:50 -04:00
Brahim Hadricheandgithub-action linter 8b123b18f5 Watching progress (#609)
* Watching progress

* watch time endpoint

* Lint fix

* Changelog

* options mandatory

* tweak

* tweak

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
2025-05-19 17:35:35 -04:00
Brahim Hadriche 158788b42e [skip ci] typo 2025-05-17 17:37:21 -04:00
Brahim Hadriche 8d42c0213b Fix proxying in dash manifest (#607)
* Fix proxying in dash manifest

* Changelog
2025-05-17 16:25:24 -04:00
Brahim Hadriche 7c1aa80819 Fix a bug where playlists with small number of videos has duplicates 2025-05-17 15:17:43 -04:00
Brahim Hadriche 30ea007502 A couple of fixes 2025-05-17 09:42:19 -04:00
Brahim Hadriche fc7a029147 [chore] update dependencies (#606)
* update dependencies

* Backend changes
2025-05-16 23:43:10 -04:00
34 changed files with 546 additions and 245 deletions

No files matched your search

+24 -1
View File
@@ -5,6 +5,29 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.38.1] - 2025-05-20
### Fixed
- Cache issue for watch history
- Video progress not showing in web app
- Video does not continuing from previous progress when opened
## [0.38.0] - 2025-05-19
### Added
- Watch progress for YouTube accounts: Progress is saved as you watch. Progress bar is shown on video thumbnails (only on user feeds, such as recommendations, subscriptions, and watch history)
- Known bug: Watch progress doesn't update for all videos.
### Fixed
- A few issues related to Playlet backend feeds and caching
- An error when Invidious doesn't return valid video metadata
- A bug where playlists with small number of videos has duplicates
- A bug where DASH manifest was not generated correctly for proxied Invidious videos
- A bug where watch history videos repeat indefinitely
## [0.37.0] - 2025-05-16 ## [0.37.0] - 2025-05-16
### Added ### Added
@@ -12,7 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- YouTube account support. The following features are now available: - YouTube account support. The following features are now available:
- The ability to login to one or multiple accounts - The ability to login to one or multiple accounts
- Both YouTube accounts and Invidious accounts are supported side-by-side - Both YouTube accounts and Invidious accounts are supported side-by-side
- Subscritions - Subscriptions
- User playlists - User playlists
- Watch History - Watch History
- Watched videos on Playlet are added to the watch history - Watched videos on Playlet are added to the watch history
+1 -1
View File
@@ -2,7 +2,7 @@ openapi: 3.0.0
info: info:
title: Playlet Web API title: Playlet Web API
version: 0.37.0 version: 0.38.1
description: description:
Playlet Web API is a RESTful API for controlling the Playlet app on Playlet Web API is a RESTful API for controlling the Playlet app on
Roku devices. The API is intended to be used by the Playlet web app, but can Roku devices. The API is intended to be used by the Playlet web app, but can
+24 -24
View File
@@ -1,22 +1,22 @@
{ {
"name": "playlet", "name": "playlet",
"version": "0.37.0", "version": "0.38.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet", "name": "playlet",
"version": "0.37.0", "version": "0.38.1",
"hasInstallScript": true, "hasInstallScript": true,
"devDependencies": { "devDependencies": {
"@rokucommunity/bslint": "^0.8.30", "@rokucommunity/bslint": "^0.8.31",
"@types/crypto-js": "^4.2.2", "@types/crypto-js": "^4.2.2",
"@types/fs-extra": "^11.0.4", "@types/fs-extra": "^11.0.4",
"@types/node": "^22.15.17", "@types/node": "^22.15.18",
"@types/xml2js": "^0.4.14", "@types/xml2js": "^0.4.14",
"argparse": "^2.0.1", "argparse": "^2.0.1",
"brighterscript": "0.68.5", "brighterscript": "0.68.5",
"brighterscript-formatter": "^1.7.13", "brighterscript-formatter": "^1.7.14",
"cheerio": "1.0.0-rc.11", "cheerio": "1.0.0-rc.11",
"convert-svg-to-png": "^0.6.4", "convert-svg-to-png": "^0.6.4",
"crypto-js": "^4.2.0", "crypto-js": "^4.2.0",
@@ -32,12 +32,12 @@
"roku-test-automation": "^2.0.13", "roku-test-automation": "^2.0.13",
"rooibos-roku": "5.15.7", "rooibos-roku": "5.15.7",
"rounded-rect-9patch": "^1.1.2", "rounded-rect-9patch": "^1.1.2",
"semver": "^7.7.1", "semver": "^7.7.2",
"shelljs": "^0.10.0", "shelljs": "^0.10.0",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "5.8.3", "typescript": "5.8.3",
"xml2js": "^0.6.2", "xml2js": "^0.6.2",
"yaml": "^2.7.1" "yaml": "^2.8.0"
}, },
"engines": { "engines": {
"node": "20" "node": "20"
@@ -438,9 +438,9 @@
"dev": true "dev": true
}, },
"node_modules/@rokucommunity/bslint": { "node_modules/@rokucommunity/bslint": {
"version": "0.8.30", "version": "0.8.31",
"resolved": "https://registry.npmjs.org/@rokucommunity/bslint/-/bslint-0.8.30.tgz", "resolved": "https://registry.npmjs.org/@rokucommunity/bslint/-/bslint-0.8.31.tgz",
"integrity": "sha512-OMXmVslummcvvK7+b7abXtGZc2t6IaxcPG1Uq3ZoNj4qqJn0z2zZLnDjizDPR0c2kaZGI3wPTHehrGMjPbkR0Q==", "integrity": "sha512-/VsycIH2OiEoNe7fCLqbQrDnX/JoKUV3Nufg0+auCM/DhCYzL4iM965VkSBebWzwUsnQXjILaKC4fRcMjpSBPQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@@ -760,9 +760,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "22.15.17", "version": "22.15.18",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.17.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.18.tgz",
"integrity": "sha512-wIX2aSZL5FE+MR0JlvF87BNVrtFWf6AE6rxSE9X7OwnVvoyCQjpzSRJ+M87se/4QCkCiebQAqrJ0y6fwIyi7nw==", "integrity": "sha512-v1DKRfUdyW+jJhZNEI1PYy29S2YRxMV5AOO/x/SjKmW0acCIOqmbj6Haf9eHAhsPmrhlHSxEhv/1WszcLWV4cg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@@ -1360,13 +1360,13 @@
} }
}, },
"node_modules/brighterscript-formatter": { "node_modules/brighterscript-formatter": {
"version": "1.7.13", "version": "1.7.14",
"resolved": "https://registry.npmjs.org/brighterscript-formatter/-/brighterscript-formatter-1.7.13.tgz", "resolved": "https://registry.npmjs.org/brighterscript-formatter/-/brighterscript-formatter-1.7.14.tgz",
"integrity": "sha512-fv2s+9CdYufQllOiE/uLayqNGq7fqy7FmCWy8gOengrNK7pUp6BV1G+3fuhRSN7A2xLNcXIB+8q6tnCGdb6qeg==", "integrity": "sha512-rbK5lT2UZ/yD/JLryIsZC9Kng1vh4xFf9CO1tp8nMRaOTncscuD1mtMsmJXq0uQusxoRNBXB/tvSZQPKR9+SXQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"brighterscript": "^0.69.8", "brighterscript": "^0.69.9",
"glob-all": "^3.3.0", "glob-all": "^3.3.0",
"jsonc-parser": "^3.0.0", "jsonc-parser": "^3.0.0",
"source-map": "^0.7.3", "source-map": "^0.7.3",
@@ -6712,9 +6712,9 @@
} }
}, },
"node_modules/semver": { "node_modules/semver": {
"version": "7.7.1", "version": "7.7.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz",
"integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==",
"dev": true, "dev": true,
"license": "ISC", "license": "ISC",
"bin": { "bin": {
@@ -7925,16 +7925,16 @@
"dev": true "dev": true
}, },
"node_modules/yaml": { "node_modules/yaml": {
"version": "2.7.1", "version": "2.8.0",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.7.1.tgz", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.0.tgz",
"integrity": "sha512-10ULxpnOCQXxJvBgxsn9ptjq6uviG/htZKk9veJGhlqn3w/DxQ631zFF+nlQXLwmImeS5amR2dl2U8sg6U9jsQ==", "integrity": "sha512-4lLa/EcQCB0cJkyts+FpIRx5G/llPxfP6VQU5KByHEhLxY3IJCH0f0Hy1MHI8sClTvsIb8qwRJ6R/ZdlDJ/leQ==",
"dev": true, "dev": true,
"license": "ISC", "license": "ISC",
"bin": { "bin": {
"yaml": "bin.mjs" "yaml": "bin.mjs"
}, },
"engines": { "engines": {
"node": ">= 14" "node": ">= 14.6"
} }
}, },
"node_modules/yargs": { "node_modules/yargs": {
+6 -6
View File
@@ -1,16 +1,16 @@
{ {
"name": "playlet", "name": "playlet",
"version": "0.37.0", "version": "0.38.1",
"description": "Unofficial YouTube client for Roku", "description": "Unofficial YouTube client for Roku",
"devDependencies": { "devDependencies": {
"@rokucommunity/bslint": "^0.8.30", "@rokucommunity/bslint": "^0.8.31",
"@types/crypto-js": "^4.2.2", "@types/crypto-js": "^4.2.2",
"@types/fs-extra": "^11.0.4", "@types/fs-extra": "^11.0.4",
"@types/node": "^22.15.17", "@types/node": "^22.15.18",
"@types/xml2js": "^0.4.14", "@types/xml2js": "^0.4.14",
"argparse": "^2.0.1", "argparse": "^2.0.1",
"brighterscript": "0.68.5", "brighterscript": "0.68.5",
"brighterscript-formatter": "^1.7.13", "brighterscript-formatter": "^1.7.14",
"cheerio": "1.0.0-rc.11", "cheerio": "1.0.0-rc.11",
"convert-svg-to-png": "^0.6.4", "convert-svg-to-png": "^0.6.4",
"crypto-js": "^4.2.0", "crypto-js": "^4.2.0",
@@ -26,12 +26,12 @@
"roku-test-automation": "^2.0.13", "roku-test-automation": "^2.0.13",
"rooibos-roku": "5.15.7", "rooibos-roku": "5.15.7",
"rounded-rect-9patch": "^1.1.2", "rounded-rect-9patch": "^1.1.2",
"semver": "^7.7.1", "semver": "^7.7.2",
"shelljs": "^0.10.0", "shelljs": "^0.10.0",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "5.8.3", "typescript": "5.8.3",
"xml2js": "^0.6.2", "xml2js": "^0.6.2",
"yaml": "^2.7.1" "yaml": "^2.8.0"
}, },
"engines": { "engines": {
"node": "20" "node": "20"
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "playlet-app", "name": "playlet-app",
"version": "0.37.0", "version": "0.38.1",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet-app", "name": "playlet-app",
"version": "0.37.0" "version": "0.38.1"
} }
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "playlet-app", "name": "playlet-app",
"version": "0.37.0", "version": "0.38.1",
"description": "Unofficial YouTube client for Roku", "description": "Unofficial YouTube client for Roku",
"scripts": { "scripts": {
"prebuild": "rm -rf ../build/playlet-app", "prebuild": "rm -rf ../build/playlet-app",
+2 -2
View File
@@ -2,8 +2,8 @@ title=Playlet
# Do not update version manually, it is auto updated from package.json # Do not update version manually, it is auto updated from package.json
major_version=0 major_version=0
minor_version=37 minor_version=38
build_version=00000 build_version=00001
ui_resolutions=hd ui_resolutions=hd
uri_resolution_autosub=$$RES$$,480p,720p,1080p uri_resolution_autosub=$$RES$$,480p,720p,1080p
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "playlet-lib", "name": "playlet-lib",
"version": "0.37.0", "version": "0.38.1",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet-lib", "name": "playlet-lib",
"version": "0.37.0" "version": "0.38.1"
} }
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "playlet-lib", "name": "playlet-lib",
"version": "0.37.0", "version": "0.38.1",
"description": "Unofficial YouTube client for Roku", "description": "Unofficial YouTube client for Roku",
"scripts": { "scripts": {
"prebuild": "rm -rf ../build/playlet-lib", "prebuild": "rm -rf ../build/playlet-lib",
@@ -54,18 +54,19 @@ function PlaylistContentTask(input as object) as object
} }
end if end if
beforeChildCount = contentNode.getChildCount()
InvidiousContent.ToPlaylistContentNode(contentNode, metadata, instance) InvidiousContent.ToPlaylistContentNode(contentNode, metadata, instance)
childCount = contentNode.getChildCount() afterChildCount = contentNode.getChildCount()
videoCount = ValidInt(metadata.videoCount) videoCount = ValidInt(metadata.videoCount)
hasContinuation = not StringUtils.IsNullOrEmpty(metadata.continuation) hasContinuation = not StringUtils.IsNullOrEmpty(metadata.continuation)
noMoreContinuation = hadContinuation and not hasContinuation noMoreContinuation = hadContinuation and not hasContinuation
noVideosReturned = metadata.videos.Count() = 0 noVideosAdded = afterChildCount = beforeChildCount
reachedVideoCount = videoCount <> -1 and childCount >= videoCount reachedVideoCount = videoCount <> -1 and afterChildCount >= videoCount
if noMoreContinuation or noVideosReturned or reachedVideoCount if noMoreContinuation or noVideosAdded or reachedVideoCount
contentNode.loadState = FeedLoadState.Loaded contentNode.loadState = FeedLoadState.Loaded
return { return {
success: true success: true
@@ -23,5 +23,6 @@
<field id="videoId" type="string" /> <field id="videoId" type="string" />
<field id="viewCountText" type="string" /> <field id="viewCountText" type="string" />
<field id="lines" type="stringarray" /> <field id="lines" type="stringarray" />
<field id="percentDurationWatched" type="float" />
</interface> </interface>
</component> </component>
@@ -12,7 +12,6 @@ class DashManifest
m.invidiousInstance = invidiousInstance m.invidiousInstance = invidiousInstance
m.utils = new Http.Utils() m.utils = new Http.Utils()
m.urlRegex = /https?:\/\/\S+(\/\S+)/i
' https://github.com/LuanRT/YouTube.js/blob/6082b4a52ee07a622735e6e9128a0531a5ae3bfb/src/utils/StreamingInfo.ts#L332-L349 ' https://github.com/LuanRT/YouTube.js/blob/6082b4a52ee07a622735e6e9128a0531a5ae3bfb/src/utils/StreamingInfo.ts#L332-L349
m.colorInfo = { m.colorInfo = {
@@ -38,8 +37,11 @@ class DashManifest
adaptiveFormats.Append(metadata.adaptiveFormats) adaptiveFormats.Append(metadata.adaptiveFormats)
if local if local
parsedInvidiousUrl = UrlUtils.ParseUrl(m.invidiousInstance)
for i = 0 to adaptiveFormats.Count() - 1 for i = 0 to adaptiveFormats.Count() - 1
adaptiveFormats[i].url = m.urlRegex.replace(adaptiveFormats[i].url, m.invidiousInstance + "\1") parsedUrl = UrlUtils.ParseUrl(adaptiveFormats[i].url)
parsedInvidiousUrl.path = UrlUtils.AppendQueryParams(parsedUrl.path, { host: parsedUrl.host })
adaptiveFormats[i].url = UrlUtils.BuildUrlFromParts(parsedInvidiousUrl)
end for end for
end if end if
@@ -312,11 +312,21 @@ namespace InnertubeService
} }
end if end if
json = response.Json() feeds = Innertube.ParseResponseDataForFeeds(response.Json())
return Innertube.ParseResponseDataForFeeds(json)
result = {
feeds: feeds
}
cacheControl = Innertube.ParseResponseForCacheControl(response)
if cacheControl <> invalid
result["cache-control"] = cacheControl
end if
return result
end function end function
function AuthMarkVideoWatched(videoId as string, options as object) as boolean function AuthGetPlaybackTrackingUrls(videoId as string, options as object) as object
cancellation = invalid cancellation = invalid
accessToken = options.accessToken accessToken = options.accessToken
@@ -330,43 +340,95 @@ namespace InnertubeService
playerResponse = playerRequest.Await() playerResponse = playerRequest.Await()
if not playerResponse.IsSuccess() if not playerResponse.IsSuccess()
LogError("Error marking video as watched:", playerResponse.ErrorMessage()) return {
return false error: playerResponse.ErrorMessage()
end if }
if CancellationUtils.IsCancelled(cancellation)
return false
end if end if
json = playerResponse.Json() json = playerResponse.Json()
videostatsPlaybackUrl = ObjectUtils.Dig(json, ["playbackTracking", "videostatsPlaybackUrl", "baseUrl"]) videostatsPlaybackUrl = ObjectUtils.Dig(json, ["playbackTracking", "videostatsPlaybackUrl", "baseUrl"])
if StringUtils.IsNullOrEmpty(videostatsPlaybackUrl) videostatsWatchtimeUrl = ObjectUtils.Dig(json, ["playbackTracking", "videostatsWatchtimeUrl", "baseUrl"])
LogError("No videostatsPlaybackUrl found in response")
return false return {
videostatsPlaybackUrl: videostatsPlaybackUrl
videostatsWatchtimeUrl: videostatsWatchtimeUrl
}
end function
function AuthMarkVideoWatched(videostatsPlaybackUrl as string, options as object) as boolean
cancellation = invalid
accessToken = options.accessToken
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if end if
videostatsPlaybackUrl = videostatsPlaybackUrl.replace("https://s.youtube.com", "https://www.youtube.com") videostatsPlaybackUrl = videostatsPlaybackUrl.replace("https://s.", "https://www.")
queryParams = UrlUtils.ParseQueryComponents(videostatsPlaybackUrl) queryParams = UrlUtils.ParseQueryComponents(videostatsPlaybackUrl)
queryParams["c"] = "TVHTML5" queryParams["c"] = "TVHTML5"
queryParams["cbrver"] = INNERTUBE_TV_CLIENT_VERSION queryParams["cbrver"] = INNERTUBE_TV_CLIENT_VERSION
queryParams["cver"] = INNERTUBE_TV_CLIENT_VERSION queryParams["cver"] = INNERTUBE_TV_CLIENT_VERSION
queryParams["cpn"] = InnertubeService.CreateClientPlaybackNonce()
queryParams["fmt"] = "251"
queryParams["rtn"] = "0"
queryParams["rt"] = "0"
queryParams["ver"] = "2" queryParams["ver"] = "2"
queryParams["cpn"] = InnertubeService.CreateClientPlaybackNonce()
queryParams["cmt"] = 0
queryParams["final"] = "1"
videostatsPlaybackUrl = UrlUtils.SetQueryParams(videostatsPlaybackUrl, queryParams) videostatsPlaybackUrl = UrlUtils.SetQueryParams(videostatsPlaybackUrl, queryParams)
trackingRequest = HttpClient.Get(videostatsPlaybackUrl) request = HttpClient.Get(videostatsPlaybackUrl)
trackingRequest.Header("Authorization", "Bearer " + accessToken) request.Cancellation(cancellation)
request.NoCache()
request.Headers(Innertube.CreateHeaders(Innertube.ClientType.Tv))
request.Header("Authorization", "Bearer " + accessToken)
trackingResponse = trackingRequest.Await() response = request.Await()
if not trackingResponse.IsSuccess() if not response.IsSuccess()
LogError("Error marking video as watched:", trackingResponse.ErrorMessage()) LogError("Error marking video as watched:", response.ErrorMessage())
return false return false
end if end if
LogDebug("Marked video as watched:", videoId) LogDebug("Marked video as watched")
return true
end function
function AuthMarkVideoWatchTime(time as float, videostatsWatchtimeUrl as string, options = invalid as object) as boolean
cancellation = invalid
accessToken = options.accessToken
if options <> invalid
if options.DoesExist("cancellation")
cancellation = options.cancellation
end if
end if
timeStr = time.ToStr("%.3f")
videostatsWatchtimeUrl = videostatsWatchtimeUrl.replace("https://s.", "https://www.")
queryParams = UrlUtils.ParseQueryComponents(videostatsWatchtimeUrl)
queryParams["c"] = "TVHTML5"
queryParams["cbrver"] = INNERTUBE_TV_CLIENT_VERSION
queryParams["cver"] = INNERTUBE_TV_CLIENT_VERSION
queryParams["ver"] = "2"
queryParams["cpn"] = InnertubeService.CreateClientPlaybackNonce()
queryParams["cmt"] = 0
queryParams["final"] = "1"
queryParams["st"] = timeStr
queryParams["et"] = timeStr
videostatsWatchtimeUrl = UrlUtils.SetQueryParams(videostatsWatchtimeUrl, queryParams)
request = HttpClient.Get(videostatsWatchtimeUrl)
request.Cancellation(cancellation)
request.NoCache()
request.Headers(Innertube.CreateHeaders(Innertube.ClientType.Tv))
request.Header("Authorization", "Bearer " + accessToken)
response = request.Await()
if not response.IsSuccess()
LogError("Error marking video watch time:", response.ErrorMessage())
return false
end if
LogDebug("Marked video watch time:", timeStr)
return true return true
end function end function
@@ -651,7 +713,14 @@ namespace InnertubeService
return response.Json() return response.Json()
end if end if
return Innertube.ParseMixPageResponseData(response.Json()) result = Innertube.ParseMixPageResponseData(response.Json())
cacheControl = Innertube.ParseResponseForCacheControl(response)
if cacheControl <> invalid
result["cache-control"] = cacheControl
end if
return result
end function end function
function ResolveUrl(url as string, options = invalid as object) as object function ResolveUrl(url as string, options = invalid as object) as object
@@ -106,6 +106,8 @@ namespace Innertube
"genericPromoRenderer": ParseNotImplemented "genericPromoRenderer": ParseNotImplemented
' "Sign in to see the latest videos tailored to your interests" ' "Sign in to see the latest videos tailored to your interests"
"feedNudgeRenderer": ParseNotImplemented "feedNudgeRenderer": ParseNotImplemented
' "No results found, Try different keywords or remove search filters"
"backgroundPromoRenderer": ParseNotImplemented
"videoSurveyShelfRenderer": ParseNotImplemented "videoSurveyShelfRenderer": ParseNotImplemented
"searchBarRenderer": ParseNotImplemented "searchBarRenderer": ParseNotImplemented
"clickTrackingParams": ParseNotImplemented "clickTrackingParams": ParseNotImplemented
@@ -927,6 +929,13 @@ namespace Innertube
function ParseTileRenderer(nodeData as object, context as object) as object function ParseTileRenderer(nodeData as object, context as object) as object
contentType = ValidString(nodeData["contentType"]) contentType = ValidString(nodeData["contentType"])
' A tileRenderer can be without a contentType, such as a
' button that says "Open YouTube Kids" or similar CTAs
if contentType = ""
LogWarn(`TileRenderer without contentType:\n`, nodeData)
return invalid
end if
if contentType = "TILE_CONTENT_TYPE_VIDEO" if contentType = "TILE_CONTENT_TYPE_VIDEO"
return TileRendererTypeVideo(nodeData, context) return TileRendererTypeVideo(nodeData, context)
else if contentType = "TILE_CONTENT_TYPE_PLAYLIST" else if contentType = "TILE_CONTENT_TYPE_PLAYLIST"
@@ -961,6 +970,7 @@ namespace Innertube
lengthText = "" lengthText = ""
isUpcoming = false isUpcoming = false
liveNow = false liveNow = false
percentDurationWatched = 0
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
@@ -968,6 +978,10 @@ namespace Innertube
if maybeLengthText <> "" if maybeLengthText <> ""
lengthText = maybeLengthText lengthText = maybeLengthText
end if end if
maybePercentDurationWatched = ObjectUtils.Dig(overlay, ["thumbnailOverlayResumePlaybackRenderer", "percentDurationWatched"])
if maybePercentDurationWatched <> invalid
percentDurationWatched = maybePercentDurationWatched
end if
liveNow = liveNow or (ValidString(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "style"])) = "LIVE") liveNow = liveNow or (ValidString(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "style"])) = "LIVE")
isUpcoming = isUpcoming or (ValidString(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "style"])) = "UPCOMING") isUpcoming = isUpcoming or (ValidString(ObjectUtils.Dig(overlay, ["thumbnailOverlayTimeStatusRenderer", "style"])) = "UPCOMING")
end for end for
@@ -996,6 +1010,7 @@ namespace Innertube
"liveNow": liveNow "liveNow": liveNow
"isUpcoming": isUpcoming "isUpcoming": isUpcoming
"lines": renderedLines "lines": renderedLines
"percentDurationWatched": percentDurationWatched
} }
PushFeedItem(video, context) PushFeedItem(video, context)
@@ -85,7 +85,7 @@ namespace Invidious
return instance return instance
end function end function
function MarkVideoWatched(videoId as dynamic) as void function MarkVideoWatched(videoId as dynamic, cancellation = invalid as object) as void
if StringUtils.IsNullOrEmpty(videoId) if StringUtils.IsNullOrEmpty(videoId)
return return
end if end if
@@ -98,6 +98,7 @@ namespace Invidious
url = `${authToken.instance}${Invidious.HISTORY_ENDPOINT}/${videoId}` url = `${authToken.instance}${Invidious.HISTORY_ENDPOINT}/${videoId}`
request = HttpClient.Post(url, "") request = HttpClient.Post(url, "")
request.Headers(m.GetAuthenticationHeaders(authToken.token)) request.Headers(m.GetAuthenticationHeaders(authToken.token))
request.Cancellation(cancellation)
request.Await() request.Await()
end function end function
@@ -52,6 +52,7 @@ namespace InvidiousContent
node.viewCountText = VideoGetViewCountText(item) node.viewCountText = VideoGetViewCountText(item)
SetIfExists(node, "index", item, "index") SetIfExists(node, "index", item, "index")
SetIfExists(node, "lines", item, "lines") SetIfExists(node, "lines", item, "lines")
SetIfExists(node, "percentDurationWatched", item, "percentDurationWatched")
return node return node
end function end function
@@ -80,19 +81,38 @@ namespace InvidiousContent
SetIfExists(node, "statsText", item, "statsText") SetIfExists(node, "statsText", item, "statsText")
SetIfExists(node, "lines", item, "lines") SetIfExists(node, "lines", item, "lines")
if item.videos <> invalid if IsArray(item.videos) and item.videos.Count() > 0
childCount = node.getChildCount() childCount = node.getChildCount()
' Innertube's TV client doesn't return the index for videos in playlists.
' So we rely on video ids to detect duplicates.
videosHasIndex = IsInt(item.videos[0].index)
videoIds = invalid
if not videosHasIndex
videoIds = {}
childVideos = node.getChildren(-1, 0)
for each child in childVideos
videoIds[child.videoId] = true
end for
end if
newNodes = [] newNodes = []
for each video in item.videos for each video in item.videos
' TODO:P1 sometimes we're parsing "recommended playlists" that ' Sometimes we're parsing "recommended playlists" that show up
' show up in the end of the playlist. We should ignore them, ' in the end of the playlist. In this context they are ignored.
' until the parsing is fixed.
if ValidString(video.type) = "playlist" if ValidString(video.type) = "playlist"
continue for continue for
end if end if
video.type = "video" video.type = "video"
videoNode = ToVideoContentNode(invalid, video, instance) videoNode = ToVideoContentNode(invalid, video, instance)
if videoNode <> invalid if videoNode <> invalid
if not videosHasIndex
if videoIds[video.videoId] = true
continue for
end if
end if
index = video.index index = video.index
if index <> invalid and index > -1 and index < childCount if index <> invalid and index > -1 and index < childCount
node.replaceChild(videoNode, index) node.replaceChild(videoNode, index)
@@ -101,6 +121,7 @@ namespace InvidiousContent
end if end if
end if end if
end for end for
if newNodes.Count() > 0 if newNodes.Count() > 0
node.appendChildren(newNodes) node.appendChildren(newNodes)
end if end if
@@ -1,4 +1,5 @@
import "pkg:/source/utils/Locale.bs" import "pkg:/source/utils/Locale.bs"
import "pkg:/source/utils/MathUtils.bs"
import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/TimeUtils.bs" import "pkg:/source/utils/TimeUtils.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
@@ -8,6 +9,7 @@ function Init()
m.durationLabel = m.top.FindNode("durationLabel") m.durationLabel = m.top.FindNode("durationLabel")
m.smallestSystemFont = m.top.FindNode("smallestSystemFont") m.smallestSystemFont = m.top.FindNode("smallestSystemFont")
m.smallestBoldSystemFont = m.top.FindNode("smallestBoldSystemFont") m.smallestBoldSystemFont = m.top.FindNode("smallestBoldSystemFont")
m.progressRect = m.top.FindNode("progressRect")
end function end function
function OnContentSet() as void function OnContentSet() as void
@@ -53,6 +55,8 @@ function OnContentSet() as void
m.top.thumbnailUri = content.thumbnail m.top.thumbnailUri = content.thumbnail
m.top.percentDurationWatched = content.percentDurationWatched
if not StringUtils.IsNullOrEmpty(content.lengthText) if not StringUtils.IsNullOrEmpty(content.lengthText)
SetDurationLabel(content.lengthText, "#161616FF", 0.8, m.smallestSystemFont) SetDurationLabel(content.lengthText, "#161616FF", 0.8, m.smallestSystemFont)
m.top.durationRectVisible = true m.top.durationRectVisible = true
@@ -90,3 +94,11 @@ function SetDurationLabel(text as string, bgColor as string, bgOpacity as float,
rect.opacity = bgOpacity rect.opacity = bgOpacity
end function end function
function OnPercentDurationWatched() as void
if m.progressRect = invalid
return
end if
percent = MathUtils.Clamp(m.top.percentDurationWatched, 0, 100) / 100.0
m.progressRect.scale = [percent, 1]
end function
@@ -8,6 +8,7 @@
<field id="durationRectVisible" type="boolean" alias="durationRect.visible" /> <field id="durationRectVisible" type="boolean" alias="durationRect.visible" />
<field id="duration" type="string" alias="durationLabel.text" /> <field id="duration" type="string" alias="durationLabel.text" />
<field id="thumbnailUri" type="string" alias="thumbnail.uri" /> <field id="thumbnailUri" type="string" alias="thumbnail.uri" />
<field id="percentDurationWatched" type="float" onChange="OnPercentDurationWatched" />
</interface> </interface>
<children> <children>
<Font id="smallestSystemFont" uri="font:SystemFontFile" size="18" /> <Font id="smallestSystemFont" uri="font:SystemFontFile" size="18" />
@@ -36,6 +37,14 @@
font="font:SmallestSystemFont" font="font:SmallestSystemFont"
translation="[8, 0]" /> translation="[8, 0]" />
</Rectangle> </Rectangle>
<Rectangle
id="progressRect"
width="350"
height="5"
color="#FF0000"
translation="[0, 192]"
scale="[0, 1]">
</Rectangle>
</Poster> </Poster>
<Label <Label
id="titleLabel" id="titleLabel"
@@ -1,12 +1,74 @@
import "pkg:/components/Services/Innertube/InnertubeService.bs"
import "pkg:/components/Services/Invidious/InvidiousService.bs" import "pkg:/components/Services/Invidious/InvidiousService.bs"
import "pkg:/source/utils/MessagePortUtils.bs"
@asynctask @asynctask
function MarkVideoWatchedTask(input as object) as object function MarkVideoWatchedTask(input as object) as object
videoId = input.videoId videoId = input.videoId
invidiousNode = input.invidious invidiousNode = input.invidious
authToken = input.authToken
profileType = input.profileType
cancellation = m.top.cancellation
service = new Invidious.InvidiousService(invidiousNode) if profileType = "invidious"
service.MarkVideoWatched(videoId) service = new Invidious.InvidiousService(invidiousNode)
service.MarkVideoWatched(videoId, cancellation)
return invalid
end if
if profileType <> "youtube"
LogError("MarkVideoWatchedTask: Unsupported profile type:", profileType)
return invalid
end if
playbackTrackingUrls = InnertubeService.AuthGetPlaybackTrackingUrls(videoId, {
accessToken: authToken.token
cancellation: cancellation
})
if playbackTrackingUrls.error <> invalid
LogError("MarkVideoWatchedTask: Failed to get playback tracking URLs:", playbackTrackingUrls.error)
return invalid
end if
if StringUtils.IsNullOrEmpty(playbackTrackingUrls.videostatsPlaybackUrl)
LogError("MarkVideoWatchedTask: videostatsPlaybackUrl is empty")
return invalid
end if
markedAsWatched = InnertubeService.AuthMarkVideoWatched(playbackTrackingUrls.videostatsPlaybackUrl, {
accessToken: authToken.token
cancellation: cancellation
})
if not markedAsWatched
return invalid
end if
if StringUtils.IsNullOrEmpty(playbackTrackingUrls.videostatsWatchtimeUrl)
LogError("MarkVideoWatchedTask: videostatsWatchtimeUrl is empty")
return invalid
end if
if CancellationUtils.IsCancelled(cancellation)
return invalid
end if
port = CreateObject("roMessagePort")
MessagePortUtils.ObserveFieldScopedExSafe(m.top, "watchTime", port)
CancellationUtils.ObserveCancellationScoped(cancellation, port)
while true
message = wait(60000, port)
if CancellationUtils.IsCancellationEvent(cancellation, message)
return invalid
end if
if message = invalid
continue while
end if
watchTime = message.getData()
InnertubeService.AuthMarkVideoWatchTime(watchTime, playbackTrackingUrls.videostatsWatchtimeUrl, {
accessToken: authToken.token
cancellation: cancellation
})
end while
return invalid return invalid
end function end function
@@ -140,7 +140,6 @@ namespace SponsorBlock
m.top.trickPlayBar.filledBarBlendColor = "#FF000080" m.top.trickPlayBar.filledBarBlendColor = "#FF000080"
end if end if
m.top.UnobserveFieldScoped("position")
m.top.ObserveFieldScoped("position", FuncName(OnPositionChangeSkipSponsorBlockSections)) m.top.ObserveFieldScoped("position", FuncName(OnPositionChangeSkipSponsorBlockSections))
end function end function
@@ -31,6 +31,13 @@ function VideoContentTask(input as object) as object
metadata = service.GetVideoMetadata(contentNode.videoId, { cancellation: m.top.cancellation }) metadata = service.GetVideoMetadata(contentNode.videoId, { cancellation: m.top.cancellation })
end if end if
if metadata = invalid
return {
success: false
error: "Failed to get video metadata"
}
end if
if m.top.cancel if m.top.cancel
return invalid return invalid
end if end if
@@ -21,6 +21,7 @@ function Init()
m.fullScreenHintTimer.ObserveField("fire", FuncName(OnFullScreenHintTimer)) m.fullScreenHintTimer.ObserveField("fire", FuncName(OnFullScreenHintTimer))
m.trickplayUITimer = m.top.findNode("trickplayUITimer") m.trickplayUITimer = m.top.findNode("trickplayUITimer")
m.trickplayUITimer.ObserveField("fire", FuncName(OnTrickplayUITimer)) m.trickplayUITimer.ObserveField("fire", FuncName(OnTrickplayUITimer))
m.top.notificationInterval = 1
' videoPlayingSuccess indicates if we started playing a video successfully ' videoPlayingSuccess indicates if we started playing a video successfully
' We use it to detect if we should try another link for a video, or if another error ' We use it to detect if we should try another link for a video, or if another error
@@ -126,6 +127,8 @@ function PlayWithContent(contentNode as object)
end if end if
if ValidInt(contentNode.timestamp) <> -1 if ValidInt(contentNode.timestamp) <> -1
videoContentNode.AddFields({ timestamp: contentNode.timestamp }) videoContentNode.AddFields({ timestamp: contentNode.timestamp })
else if contentNode.percentDurationWatched > 0 and contentNode.percentDurationWatched < 100
videoContentNode.AddFields({ percentDurationWatched: contentNode.percentDurationWatched })
end if end if
if not StringUtils.IsNullOrEmpty(contentNode.title) if not StringUtils.IsNullOrEmpty(contentNode.title)
videoContentNode.title = contentNode.title videoContentNode.title = contentNode.title
@@ -144,8 +147,6 @@ function StartVideoContentTask(videoContentNode as object)
m.videoContentTask.cancel = true m.videoContentTask.cancel = true
end if end if
MarkVideoWatched(videoContentNode.videoId)
m.top.content = videoContentNode m.top.content = videoContentNode
m.videoContentTask = AsyncTask.Start(Tasks.VideoContentTask, { m.videoContentTask = AsyncTask.Start(Tasks.VideoContentTask, {
@@ -194,22 +195,25 @@ function OnVideoContentTaskResults(output as object) as void
SponsorBlock.FetchSponsorBlock(content.metadata) SponsorBlock.FetchSponsorBlock(content.metadata)
timestamp = content.timestamp timestamp = content.timestamp
percentDurationWatched = content.percentDurationWatched
hasTimestamp = IsInt(timestamp) hasTimestamp = IsInt(timestamp)
hasPercentDurationWatched = IsFloat(percentDurationWatched)
if IsLiveVideo() and not hasTimestamp if IsLiveVideo() and not hasTimestamp and not hasPercentDurationWatched
duration = m.top.duration ' If live, seek to end of stream
if duration > 0 m.seekToPercent = 100.0
SeekToEndOfStream() SeekToPercentOfDuration()
else else
m.top.ObserveField("duration", FuncName(SeekToEndOfStream)) if hasTimestamp and timestamp > 0
m.top.seek = content.timestamp
else if hasPercentDurationWatched
m.seekToPercent = percentDurationWatched
SeekToPercentOfDuration()
end if end if
end if end if
PlayAfterPreviousPlayerHasStopped() PlayAfterPreviousPlayerHasStopped()
MarkVideoWatched(content.videoId)
if hasTimestamp and timestamp > 0
m.top.seek = content.timestamp
end if
end function end function
function PlayAfterPreviousPlayerHasStopped() as void function PlayAfterPreviousPlayerHasStopped() as void
@@ -272,12 +276,48 @@ function MarkVideoWatched(videoId as dynamic) as void
return return
end if end if
if m.top.invidious.authToken <> invalid invidious = m.top.invidious
AsyncTask.Start(Tasks.MarkVideoWatchedTask, { authToken = invidious.authToken
videoId: videoId if authToken = invalid
invidious: m.top.invidious return
})
end if end if
if m.markVideoWatchedTask <> invalid
m.markVideoWatchedTask.cancel = true
end if
profileType = authToken.profileNode.type
m.markVideoWatchedTask = AsyncTask.Create(Tasks.MarkVideoWatchedTask, {
videoId: videoId
invidious: invidious
authToken: authToken
profileType: profileType
})
m.markVideoWatchedTask.addField("watchTime", "float", false)
m.markVideoWatchedTask.control = "RUN"
if profileType <> "youtube"
return
end if
' Progress reported to Innertube. It is the position in seconds,
' with 20 second steps.
m.watchTimeMarker = -1
m.top.ObserveFieldScoped("position", FuncName(OnPositionChangeMarkWatchTime))
end function
function OnPositionChangeMarkWatchTime() as void
if m.markVideoWatchedTask = invalid
return
end if
currentPosition = m.top.position
currentWatchTimeMarker = m.watchTimeMarker
m.watchTimeMarker = (currentPosition \ 20) * 20
if currentWatchTimeMarker = currentPosition
return
end if
m.markVideoWatchedTask.watchTime = m.watchTimeMarker
end function end function
function OnClose() function OnClose()
@@ -285,6 +325,10 @@ function OnClose()
m.top.previousPlayer = invalid m.top.previousPlayer = invalid
if m.markVideoWatchedTask <> invalid
m.markVideoWatchedTask.cancel = true
m.markVideoWatchedTask = invalid
end if
if m.videoContentTask <> invalid if m.videoContentTask <> invalid
m.videoContentTask.cancel = true m.videoContentTask.cancel = true
m.videoContentTask = invalid m.videoContentTask = invalid
@@ -408,13 +452,43 @@ function OnVideoPlayerStateChange() as void
end if end if
end function end function
function SeekToEndOfStream() function SeekToEndOfStream() as void
m.top.UnobserveField("duration") m.top.UnobserveField("duration")
duration = m.top.duration duration = m.top.duration
' If the stream is less than 30 seconds, it's not worth seeking to the end ' If the stream is less than 30 seconds, it's not worth seeking
if duration > 30 if duration < 30
LogInfo("Seeking to end of live stream", duration) return
m.top.seek = duration end if
LogInfo("Seeking to end of live stream", duration)
m.top.seek = duration
end function
function SeekToPercentOfDuration() as void
m.top.UnobserveField("duration")
seekToPercent = m.seekToPercent
if seekToPercent = invalid
return
end if
duration = m.top.duration
if duration = 0
' If the duration is not available, wait for it to be set
m.top.ObserveField("duration", FuncName(SeekToPercentOfDuration))
return
end if
' If the stream is less than 30 seconds, it's not worth seeking
if duration < 30
return
end if
m.seekToPercent = invalid
seek = (MathUtils.Clamp(seekToPercent, 0, 100) / 100.0) * duration
if seek > 0
LogInfo("Seeking to percent duration watched", seek)
m.top.seek = seek
end if end if
end function end function
@@ -71,36 +71,35 @@ namespace Http
options.continuation = continuation options.continuation = continuation
end if end if
feeds = InnertubeService.GetSubscriptions(options) result = InnertubeService.GetSubscriptions(options)
if feeds = invalid if result.error <> invalid
response.Json({ response.Json(result)
"error": "Failed to get auth feed"
})
response.http_code = 500 response.http_code = 500
return true return true
end if end if
if IsAssociativeArray(feeds) if not IsArray(result.feeds) or result.feeds.Count() = 0
if feeds.error <> invalid ' Not an error, just no subscriptions
response.Json(feeds) response.Json({
response.http_code = 500 "videos": []
return true })
end if
return true return true
end if end if
result = { responseBody = {
"videos": [] "videos": ValidArray(result.feeds[0].items)
} }
if feeds.Count() > 0 if result.feeds[0].DoesExist("continuation")
result["videos"] = ValidArray(feeds[0].items) responseBody.continuation = result.feeds[0].continuation
if feeds[0].DoesExist("continuation") end if
result["continuation"] = feeds[0].continuation
end if response.Json(responseBody)
if result.DoesExist("cache-control")
response.headers["cache-control"] = result["cache-control"]
end if end if
response.Json(result)
return true return true
end function end function
@@ -144,8 +143,14 @@ namespace Http
options.continuation = continuation options.continuation = continuation
end if end if
feeds = InnertubeService.GetPlaylists(options) result = InnertubeService.GetPlaylists(options)
if feeds = invalid 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({ response.Json({
"error": "Failed to get auth playlists" "error": "Failed to get auth playlists"
}) })
@@ -153,23 +158,12 @@ namespace Http
return true return true
end if end if
if IsAssociativeArray(feeds) response.Json(result.feeds[0])
if feeds.error <> invalid
response.Json(feeds) if result.DoesExist("cache-control")
response.http_code = 500 response.headers["cache-control"] = result["cache-control"]
return true
end if
return true
end if end if
if feeds.Count() > 0
response.Json(feeds[0])
return true
end if
response.Json({
"items": []
})
return true return true
end function end function
@@ -190,80 +184,41 @@ namespace Http
options = { options = {
"accessToken": accessToken.Mid("Bearer ".Len()) "accessToken": accessToken.Mid("Bearer ".Len())
} }
continuation = request.query.continuation continuation = request.query.continuation
if not StringUtils.IsNullOrEmpty(continuation) hasContinuation = not StringUtils.IsNullOrEmpty(continuation)
if hasContinuation
options.continuation = continuation options.continuation = continuation
end if end if
feeds = InnertubeService.GetWatchHistory(options) if not hasContinuation
if feeds = invalid page = ValidString(request.query.page).ToInt()
response.Json({ if page > 1
"error": "Failed to get auth history" LogError("Playlet backend does not use history pagination (use continuation instead)")
}) response.Json({
response.http_code = 500 "items": []
return true })
end if
if IsAssociativeArray(feeds)
if feeds.error <> invalid
response.Json(feeds)
response.http_code = 500
return true return true
end if end if
return true
end if end if
if feeds.Count() > 0 result = InnertubeService.GetWatchHistory(options)
response.Json(feeds[0]) if result.error <> invalid
return true response.Json(result)
end if
response.Json({
"items": []
})
return true
end function
function AuthMarkVideoWatched(context as object) as boolean
request = context.request
response = context.response
route = request.route
accessToken = request.headers["authorization"]
if StringUtils.IsNullOrEmpty(accessToken) or not accessToken.StartsWith("Bearer ")
response.Json({
"error": "Missing or invalid 'Authorization' header"
})
response.http_code = 403
return true
end if
videoId = route.Mid("/playlet-invidious-backend/api/v1/auth/history/".Len())
if videoId.InStr("?") > 0
videoId = videoId.Left(videoId.InStr("?"))
end if
if StringUtils.IsNullOrEmpty(videoId)
response.Json({
"error": "Missing 'videoId' path parameter"
})
response.http_code = 400
return true
end if
options = {
"accessToken": accessToken.Mid("Bearer ".Len())
}
if not InnertubeService.AuthMarkVideoWatched(videoId, options)
response.Json({
"error": "Failed to mark video as watched"
})
response.http_code = 500 response.http_code = 500
return true return true
end if end if
response.Default(204, "OK") if not IsArray(result.feeds) or result.feeds.Count() = 0
' Not an error, just no history
response.Json({
"items": []
})
return true
end if
response.Json(result.feeds[0])
return true return true
end function end function
@@ -317,6 +272,7 @@ namespace Http
end if end if
response.Json(ValidArray(result.feeds[0].items)) response.Json(ValidArray(result.feeds[0].items))
if result.DoesExist("cache-control") if result.DoesExist("cache-control")
response.headers["cache-control"] = result["cache-control"] response.headers["cache-control"] = result["cache-control"]
end if end if
@@ -346,36 +302,27 @@ namespace Http
options.continuation = continuation options.continuation = continuation
end if end if
feeds = InnertubeService.GetHome(options) result = InnertubeService.GetHome(options)
if feeds = invalid if result.error <> invalid
response.Json({ response.Json(result)
"error": "Failed to get auth home feed"
})
response.http_code = 500 response.http_code = 500
return true return true
end if end if
if IsAssociativeArray(feeds) if not IsArray(result.feeds) or result.feeds.Count() = 0
if feeds.error <> invalid ' Not an error, just no recommended videos, usually when there's no history
response.Json(feeds) response.Json({
response.http_code = 500 "items": []
return true })
end if
return true return true
end if end if
result = { response.Json(result.feeds[0])
"items": []
}
if feeds.Count() > 0 if result.DoesExist("cache-control")
result["items"] = ValidArray(feeds[0].items) response.headers["cache-control"] = result["cache-control"]
if feeds[0].DoesExist("continuation")
result["continuation"] = feeds[0].continuation
end if
end if end if
response.Json(result)
return true return true
end function end function
@@ -460,7 +407,7 @@ namespace Http
if not IsArray(result.feeds) or result.feeds.Count() = 0 if not IsArray(result.feeds) or result.feeds.Count() = 0
response.Json({ response.Json({
"error": "Failed to search" "error": "Failed to search: no results found"
}) })
response.http_code = 500 response.http_code = 500
return true return true
@@ -581,9 +528,7 @@ namespace Http
request = context.request request = context.request
route = request.route route = request.route
if route.StartsWith("/playlet-invidious-backend/api/v1/auth/history/") if route.StartsWith("/playlet-invidious-backend/api/v1/auth/subscriptions/")
return m.AuthMarkVideoWatched(context)
else if route.StartsWith("/playlet-invidious-backend/api/v1/auth/subscriptions/")
return m.SubscribeToChannel(context) return m.SubscribeToChannel(context)
end if end if
@@ -44,6 +44,12 @@ namespace Http
return true return true
end if end if
if IsString(payload.timestamp)
payload.timestamp = payload.timestamp.toInt()
else if IsString(payload.percentDurationWatched)
payload.percentDurationWatched = payload.percentDurationWatched.toFloat()
end if
instance = m.invidiousService.GetInstance() instance = m.invidiousService.GetInstance()
contentNode = InvidiousContent.ToRowCellContentNode(payload, instance) contentNode = InvidiousContent.ToRowCellContentNode(payload, instance)
@@ -79,6 +85,8 @@ namespace Http
if IsString(payload.timestamp) if IsString(payload.timestamp)
payload.timestamp = payload.timestamp.toInt() payload.timestamp = payload.timestamp.toInt()
else if IsString(payload.percentDurationWatched)
payload.percentDurationWatched = payload.percentDurationWatched.toFloat()
end if end if
instance = m.invidiousService.GetInstance() instance = m.invidiousService.GetInstance()
+2 -2
View File
@@ -2,8 +2,8 @@ title=PlayletLib
# Do not update version manually, it is auto updated from package.json # Do not update version manually, it is auto updated from package.json
major_version=0 major_version=0
minor_version=37 minor_version=38
build_version=00000 build_version=00001
ui_resolutions=hd ui_resolutions=hd
uri_resolution_autosub=$$RES$$,480p,720p,1080p uri_resolution_autosub=$$RES$$,480p,720p,1080p
@@ -1,6 +1,6 @@
namespace MessagePortUtils namespace MessagePortUtils
function ObserveFieldScopedExSafe(node as dynamic, field as string, port as dynamic) function ObserveFieldScopedExSafe(node as dynamic, field as string, port as dynamic) as void
' ObserveFieldScopedEx was added in 12.0 ' ObserveFieldScopedEx was added in 12.0
if FindMemberFunction(node, "ObserveFieldScopedEx") <> invalid if FindMemberFunction(node, "ObserveFieldScopedEx") <> invalid
' bs:disable-next-line NO_OBSERVE_FIELD_SCOPED_EX ' bs:disable-next-line NO_OBSERVE_FIELD_SCOPED_EX
+24
View File
@@ -246,4 +246,28 @@ namespace UrlUtils
} }
end function end function
function BuildUrlFromParts(parts as object) as string
url = ""
if not StringUtils.IsNullOrEmpty(parts.protocol)
url += parts.protocol + "://"
end if
if not StringUtils.IsNullOrEmpty(parts.host)
url += parts.host
end if
if (not StringUtils.IsNullOrEmpty(parts.port)) and ((parts.protocol = "http" and parts.port <> "80") or (parts.protocol = "https" and parts.port <> "443") or (parts.protocol <> "http" and parts.protocol <> "https"))
url += ":" + parts.port
end if
if not StringUtils.IsNullOrEmpty(parts.path)
if not parts.path.StartsWith("/")
url += "/"
end if
url += parts.path
end if
return url
end function
end namespace end namespace
+15 -15
View File
@@ -1,12 +1,12 @@
{ {
"name": "playlet-web", "name": "playlet-web",
"version": "0.37.0", "version": "0.38.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "playlet-web", "name": "playlet-web",
"version": "0.37.0", "version": "0.38.1",
"devDependencies": { "devDependencies": {
"@sveltejs/vite-plugin-svelte": "^5.0.3", "@sveltejs/vite-plugin-svelte": "^5.0.3",
"@tailwindcss/typography": "^0.5.16", "@tailwindcss/typography": "^0.5.16",
@@ -17,11 +17,11 @@
"dotenv": "^16.5.0", "dotenv": "^16.5.0",
"ip": "^2.0.1", "ip": "^2.0.1",
"postcss": "^8.5.3", "postcss": "^8.5.3",
"svelte": "^5.28.2", "svelte": "^5.30.1",
"svelte-check": "^4.1.7", "svelte-check": "^4.2.1",
"svelte-preprocess": "^6.0.3", "svelte-preprocess": "^6.0.3",
"tailwindcss": "^3.4.17", "tailwindcss": "^3.4.17",
"terser": "^5.39.0", "terser": "^5.39.2",
"tslib": "^2.8.1", "tslib": "^2.8.1",
"typescript": "^5.8.3", "typescript": "^5.8.3",
"vite": "^6.3.5", "vite": "^6.3.5",
@@ -4371,9 +4371,9 @@
} }
}, },
"node_modules/svelte": { "node_modules/svelte": {
"version": "5.28.2", "version": "5.30.1",
"resolved": "https://registry.npmjs.org/svelte/-/svelte-5.28.2.tgz", "resolved": "https://registry.npmjs.org/svelte/-/svelte-5.30.1.tgz",
"integrity": "sha512-FbWBxgWOpQfhKvoGJv/TFwzqb4EhJbwCD17dB0tEpQiw1XyUEKZJtgm4nA4xq3LLsMo7hu5UY/BOFmroAxKTMg==", "integrity": "sha512-QIYtKnJGkubWXtNkrUBKVCvyo9gjcccdbnvXfwsGNhvbeNNdQjRDTa/BiQcJ2kWXbXPQbWKyT7CUu53KIj1rfw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@@ -4397,9 +4397,9 @@
} }
}, },
"node_modules/svelte-check": { "node_modules/svelte-check": {
"version": "4.1.7", "version": "4.2.1",
"resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-4.1.7.tgz", "resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-4.2.1.tgz",
"integrity": "sha512-1jX4BzXrQJhC/Jt3SqYf6Ntu//vmfc6VWp07JkRfK2nn+22yIblspVUo96gzMkg0Zov8lQicxhxsMzOctwcMQQ==", "integrity": "sha512-e49SU1RStvQhoipkQ/aonDhHnG3qxHSBtNfBRb9pxVXoa+N7qybAo32KgA9wEb2PCYFNaDg7bZCdhLD1vHpdYA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@@ -4592,14 +4592,14 @@
} }
}, },
"node_modules/terser": { "node_modules/terser": {
"version": "5.39.0", "version": "5.39.2",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.39.0.tgz", "resolved": "https://registry.npmjs.org/terser/-/terser-5.39.2.tgz",
"integrity": "sha512-LBAhFyLho16harJoWMg/nZsQYgTrg5jXOn2nCYjRUcZZEdE3qa2zb8QEDRUGVZBW4rlazf2fxkg8tztybTaqWw==", "integrity": "sha512-yEPUmWve+VA78bI71BW70Dh0TuV4HHd+I5SHOAfS1+QBOmvmCiiffgjR8ryyEd3KIfvPGFqoADt8LdQ6XpXIvg==",
"dev": true, "dev": true,
"license": "BSD-2-Clause", "license": "BSD-2-Clause",
"dependencies": { "dependencies": {
"@jridgewell/source-map": "^0.3.3", "@jridgewell/source-map": "^0.3.3",
"acorn": "^8.8.2", "acorn": "^8.14.0",
"commander": "^2.20.0", "commander": "^2.20.0",
"source-map-support": "~0.5.20" "source-map-support": "~0.5.20"
}, },
+4 -4
View File
@@ -1,6 +1,6 @@
{ {
"name": "playlet-web", "name": "playlet-web",
"version": "0.37.0", "version": "0.38.1",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
@@ -18,11 +18,11 @@
"dotenv": "^16.5.0", "dotenv": "^16.5.0",
"ip": "^2.0.1", "ip": "^2.0.1",
"postcss": "^8.5.3", "postcss": "^8.5.3",
"svelte": "^5.28.2", "svelte": "^5.30.1",
"svelte-check": "^4.1.7", "svelte-check": "^4.2.1",
"svelte-preprocess": "^6.0.3", "svelte-preprocess": "^6.0.3",
"tailwindcss": "^3.4.17", "tailwindcss": "^3.4.17",
"terser": "^5.39.0", "terser": "^5.39.2",
"tslib": "^2.8.1", "tslib": "^2.8.1",
"typescript": "^5.8.3", "typescript": "^5.8.3",
"vite": "^6.3.5", "vite": "^6.3.5",
+14
View File
@@ -78,6 +78,13 @@ export class PlayletApi {
args.timestamp = parseInt(args.timestamp); args.timestamp = parseInt(args.timestamp);
} }
} }
if (args.percentDurationWatched !== undefined) {
if (typeof args.percentDurationWatched === "string") {
args.percentDurationWatched = parseFloat(args.percentDurationWatched);
}
}
await PlayletApi.postJson(`${PlayletApi.host()}/api/queue/play`, args); await PlayletApi.postJson(`${PlayletApi.host()}/api/queue/play`, args);
} }
@@ -99,6 +106,13 @@ export class PlayletApi {
args.timestamp = parseInt(args.timestamp); args.timestamp = parseInt(args.timestamp);
} }
} }
if (args.percentDurationWatched !== undefined) {
if (typeof args.percentDurationWatched === "string") {
args.percentDurationWatched = parseFloat(args.percentDurationWatched);
}
}
await PlayletApi.postJson(`${PlayletApi.host()}/api/queue`, args); await PlayletApi.postJson(`${PlayletApi.host()}/api/queue`, args);
} }
@@ -14,6 +14,7 @@
export let viewCount: number | undefined = undefined; export let viewCount: number | undefined = undefined;
export let isUpcoming: boolean = undefined; export let isUpcoming: boolean = undefined;
export let premiereTimestamp: number | undefined = undefined; export let premiereTimestamp: number | undefined = undefined;
export let percentDurationWatched: number | undefined = undefined;
export let videoStartAtChecked; export let videoStartAtChecked;
export let videoStartAtTimestamp; export let videoStartAtTimestamp;
@@ -69,6 +70,7 @@
liveNow, liveNow,
viewCount, viewCount,
timestamp, timestamp,
percentDurationWatched,
}; };
} }
@@ -103,6 +105,7 @@
bind:isUpcoming bind:isUpcoming
bind:premiereTimestamp bind:premiereTimestamp
bind:invidiousInstance bind:invidiousInstance
bind:percentDurationWatched
/> />
</div> </div>
<div class="m-4">{title || ""}</div> <div class="m-4">{title || ""}</div>
@@ -19,6 +19,7 @@
export let lengthText: string | undefined = undefined; export let lengthText: string | undefined = undefined;
export let liveNow: boolean = undefined; export let liveNow: boolean = undefined;
export let lines: string[] | undefined = undefined; export let lines: string[] | undefined = undefined;
export let percentDurationWatched: number | undefined = undefined;
// svelte-ignore unused-export-let // svelte-ignore unused-export-let
export let type: string = undefined; export let type: string = undefined;
@@ -207,6 +208,7 @@
bind:lengthText bind:lengthText
bind:viewCount bind:viewCount
bind:invidiousInstance bind:invidiousInstance
bind:percentDurationWatched
/> />
<div class="card-body"> <div class="card-body">
<h3 class="card-title text-base line-clamp-2 min-h-12">{title || ""}</h3> <h3 class="card-title text-base line-clamp-2 min-h-12">{title || ""}</h3>
@@ -243,6 +245,7 @@
bind:isUpcoming bind:isUpcoming
bind:premiereTimestamp bind:premiereTimestamp
bind:viewCount bind:viewCount
bind:percentDurationWatched
videoStartAtChecked={false} videoStartAtChecked={false}
videoStartAtTimestamp={0} videoStartAtTimestamp={0}
/> />
@@ -10,6 +10,7 @@
export let viewCount: number | undefined = undefined; export let viewCount: number | undefined = undefined;
export let isUpcoming: boolean | undefined = undefined; export let isUpcoming: boolean | undefined = undefined;
export let premiereTimestamp: number | undefined = undefined; export let premiereTimestamp: number | undefined = undefined;
export let percentDurationWatched: number | undefined = undefined;
export let invidiousInstance; export let invidiousInstance;
@@ -92,4 +93,10 @@
{getFormattedTime(lengthText, lengthSeconds)} {getFormattedTime(lengthText, lengthSeconds)}
</div> </div>
{/if} {/if}
{#if percentDurationWatched}
<div
class="absolute left-0 bottom-0 h-1 bg-red-600 rounded-box"
style="width: {Math.min(percentDurationWatched, 100)}%;"
></div>
{/if}
</figure> </figure>
+2 -1
View File
@@ -3,7 +3,8 @@ import { CompilerPlugin, Program, SourceObj } from "brighterscript";
const types = [ const types = [
{ name: 'Bool', interface: 'ifBoolean', type: 'boolean', defaultValue: 'false' }, { name: 'Bool', interface: 'ifBoolean', type: 'boolean', defaultValue: 'false' },
{ name: 'Int', interface: 'ifInt', type: 'integer', defaultValue: '0' }, { name: 'Int', interface: 'ifInt', type: 'integer', defaultValue: '0%' },
{ name: 'Float', interface: 'ifFloat', type: 'float', defaultValue: '0!' },
{ name: 'Double', interface: 'ifDouble', type: 'double', defaultValue: '0#' }, { name: 'Double', interface: 'ifDouble', type: 'double', defaultValue: '0#' },
{ name: 'String', interface: 'ifString', type: 'string', defaultValue: '""' }, { name: 'String', interface: 'ifString', type: 'string', defaultValue: '""' },
{ name: 'Array', interface: 'ifArray', type: 'object', defaultValue: '[]' }, { name: 'Array', interface: 'ifArray', type: 'object', defaultValue: '[]' },