Skip to content

webOS: play vidapi natively through a loopback relay - #45

Merged
professorDeveloper merged 9 commits into
professorDeveloper:integrating-apple-tvfrom
ArnoldDeRuiter:webos-native-relabel
Nov 6, 2026
Merged

professorDeveloper merged 9 commits into
professorDeveloper:integrating-apple-tvfrom
ArnoldDeRuiter:webos-native-relabel

Conversation

@ArnoldDeRuiter

@ArnoldDeRuiter ArnoldDeRuiter commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #41, stacked on #42 (base: integrating-apple-tv). Until #42 merges, this diff includes its commit.

Summary

The TV's native player plays vidapi as soon as its segments carry the right content type; only the text/html label stops it. The ipk now carries a small JS service that relays HLS on loopback and names the bytes by their content. Nothing is decoded or changed.

app start (webOS only)
  PalmServiceBridge → luna://com.soplay.sozo.webos.service/relay   (private; subscription keeps it alive)
    sender must be com.soplay.sozo.webos, else "caller not allowed"
    ← { port, token }
player: provider.relabel (vidapi), engine native
  <source src="http://127.0.0.1:<port>/<token>/p?u=<stream URL>">
    relay fetches the same URL (public addresses only, checked on every hop), then sniffs the first bytes
      #EXTM3U → playlist: every URI rewritten back through the relay
      0x47 / ftyp / ID3 → video/mp2t, video/mp4, audio/aac; piped, Range passed through
    bad redirect or a URL http.get rejects → 502
service missing or failing → plain URL → native fails → hls.js (#42)
 webos/
+├── service/            # com.soplay.sozo.webos.service: proxy.js, service.js, services.json, package.json
 ├── js/lib/
+│   └── relabel.js      # bridge client; wrap(url) only once the service has answered
 ├── js/player.js        # native <source> goes through relabelled(url)
 └── tools/              # stage.js stages service/; package.js packages and verifies it byte for byte
  • Loopback only, a free port, and a random per-run token in every path. Only http(s) upstreams, on the first URL and on every redirect.
  • Upstream addresses must be public: loopback, private, link-local, CGNAT, multicast and reserved ranges are refused for IPv4 and IPv6. IPv6 is normalised first, so expanded and IPv4-embedding spellings are covered. The check runs in each connection's lookup, so DNS rebinding can't get past it.
  • Non-ASCII paths are percent-encoded before the request.
  • service/ is ES5 (tested with acorn) for the oldest webOS Node.
  • ares-package prints a generic Node.js version notice for any package with a service. package.js allows that one line; any other warning still fails the build.
  • Off webOS, or without PalmServiceBridge, nothing calls the service.

Evidence

  • On an LG webOS 10.3 TV (rooted, installed through appInstallService/dev/install), with the latest commit, the same vidapi film:
    Before: native: MEDIA_ELEMENT_ERROR: Format error after 0.9 s.
    After: native through the relay: playing after 1.7 s at 1920x800, and hls.js is never loaded.
  • Same TV, latest commit, through the relay from inside Sozo: a Cyrillic path (ru.wikipedia.org/wiki/Файл) answers 200, http://[0:0:0:0:0:ffff:7f00:1]:9998/ answers 403, and the relay keeps serving afterwards. A shell luna-send to relay gets caller not allowed.
  • Tests (test/relay.test.js): byte sniffing; playlist rewriting; a round trip through a host that labels everything text/html, with a redirect, a Range request and a wrong token; LAN and loopback upstreams refused by literal address and by name; a redirect to a refused address; redirects to ftp:, javascript:, file: and a hostless URL answer 502 while the relay keeps serving; leaving mid-redirect aborts the next hop; a 6 MB segment piped intact; expanded IPv6 such as 0:0:0:0:0:0:0:1 and 0:0:0:0:0:ffff:7f00:1; Cyrillic playlist and segment names; the caller check; the bridge client; the package verifier with a service. A browser test fails without relabel: true.
  • The redirect-scheme, IPv6 and non-Latin tests fail on the earlier relay commits (ERR_INVALID_PROTOCOL, expanded IPv6 let through, 502 for /файл.ts) and pass now.
  • npm test 166/166, npm run test:browser 100/100.

Merge Danger

Door: two-way

Blast Radius: webOS packaging and vidapi playback

The ipk now installs a private service under usr/palm/services/. Not tested: Developer Mode ares-install (no Dev Mode TV available), webOS 4-6 (older Node), and the service across app suspend and resume.

@professorDeveloper

Copy link
Copy Markdown
Owner

Thanks, this is the first real-TV report we have, and it's very useful. I'll run CI and merge #42, #43 and #44 once it's green. The uz and ru strings in #44 look right.

On #45, I'd keep the relay on the device, for the reasons you gave. Before merging I'd like three things:

  • Test an install through Developer Mode ares-install, since that's the path the README gives. If you can, try an older webOS too.
  • Limit who can use the relay: relay is public: true and accepts any http(s) host, including LAN addresses.
  • Use pipe or handle backpressure on segment writes, and abort the upstream request after a redirect too.

Did sportstv play on your TV?

@professorDeveloper

Copy link
Copy Markdown
Owner

One more thing on the relay, on top of my earlier list. This one is from reading the code, I haven't reproduced it.

isUpstream checks only the first URL. A redirect goes straight back into fetchUpstream, so a host can redirect to a non-http scheme such as ftp://. http.get should then throw ERR_INVALID_PROTOCOL inside the response callback, where nothing catches it, and that would take the service down. Please run the same check on the redirect target and answer 502 if it fails, with a test.

CI passes here too (159/159 unit tests, ipk builds), but that doesn't cover the items above, so #45 stays open until they're done.

@professorDeveloper

Copy link
Copy Markdown
Owner

One more thing on the relay, on top of my earlier list. This one is from reading the code, I haven't reproduced it.

isUpstream checks only the first URL. A redirect goes straight back into fetchUpstream, so a host can redirect to a non-http scheme such as ftp://. http.get should then throw ERR_INVALID_PROTOCOL inside the response callback, where nothing catches it, and that would take the service down. Please run the same check on the redirect target and answer 502 if it fails, with a test.

CI passes here too (159/159 unit tests, ipk builds), but that doesn't cover the items above, so #45 stays open until they're done.

@ArnoldDeRuiter

@professorDeveloper

Copy link
Copy Markdown
Owner

Nice work, the four relay items look fixed to me, and CI is green (164/164 unit tests).

I spotted two small things left while reading the code. I haven't run either one through the relay itself:

  1. A path with non-Latin characters, like http://host/файл.ts, makes http.get throw ERR_UNESCAPED_CHARACTERS right away. There's no try/catch in proxy.js, so one playlist or redirect like that should take the service down. Could you percent-encode the path, or catch the throw and answer 502? A test for it would be great.
  2. isPublicAddress lets expanded IPv6 addresses through, like 0:0:0:0:0:0:0:1 and 0:0:0:0:0:ffff:7f00:1. Normalising the address before the check should cover it. Please add those two to the test as well.

A few questions too: did the last two commits run on your TV? And could you try an install through Developer Mode ares-install when you get a chance? Once that's done, please update the Evidence section in the PR so it matches.

Also, I'm curious whether sportstv played for you.

Thanks again for testing all this on a real TV, it helps a lot.

@ArnoldDeRuiter

Copy link
Copy Markdown
Contributor Author

Thanks @professorDeveloper! Everything is on #45 now (0b0eb1aa, 3aea7589, ffc565b1, 93227436), and I've updated the Evidence section to match.

  • Who can use the relay: relay only answers when message.sender is com.soplay.sozo.webos. Anything else gets caller not allowed, and the service is now public: false; Sozo still reaches it. Upstreams must resolve to public addresses, checked in each connection's own lookup on every redirect hop, so DNS rebinding can't get past it.
  • Redirect targets: you were right. On e0bb3fc7 a redirect to ftp:// threw ERR_INVALID_PROTOCOL and the relay stopped answering. Every redirect target now goes through isUpstream, and http.get is wrapped, so both give a 502. The test (redirects to ftp:, javascript:, file: and a hostless URL, then a normal request) fails on e0bb3fc7 and passes now.
  • Non-Latin paths: confirmed, /файл.ts threw ERR_UNESCAPED_CHARACTERS. Since ffc565b1 that gives a 502, but such URLs should play, so non-ASCII path characters are now percent-encoded first. The test sends a Cyrillic playlist and segment through the relay.
  • Expanded IPv6: confirmed, both of your addresses got through. IPv6 is now normalised to eight groups before the check, which also covers IPv4-mapped, 6to4, Teredo and NAT64 forms. Your two addresses and those forms are in the test.
  • Backpressure and redirects: media is piped after the first chunk is sniffed. Each redirect hop aborts its request, and the client closing aborts whichever hop is live. There are tests for a 6 MB segment arriving intact and for leaving mid-redirect.
  • On the TV: yes, every commit ran on my TV (webOS 10.3). The latest one: vidapi plays natively through the relay without hls.js; a shell luna-send to relay gets caller not allowed; a Cyrillic path answers 200; http://[0:0:0:0:0:ffff:7f00:1]:9998/ answers 403; and the relay keeps serving afterwards.
  • ares-install and older webOS: I can't test either. My TV is rooted without Developer Mode, and I'm keeping it that way. I have no older webOS set either. Installs here go through appInstallService/dev/install, the same call ares-install ends in. I tried ares-install against the TV's root SSH: the upload works, but that SSH server refuses its command step, so it's no stand-in for Dev Mode. If you need that check before merging, someone with a Dev Mode TV would have to run it; otherwise "tested on webOS 10.3 only" is the honest label.
  • sportstv: yes. Setanta Sports 1 Eurasia (stream.mcquack.net) and Futbol (185.121.1.163:8083) both played natively at 1080p over plain HTTP, without hls.js.

npm test 166/166, npm run test:browser 100/100.

@professorDeveloper

Copy link
Copy Markdown
Owner

Thanks, this is great, and CI is green (166/166). Two small things and then I think it's ready:

  1. url.parse and url.resolve still sit outside the try. On Node 26, something like http://[bad/x passes isUpstream and then throws ERR_INVALID_URL, so a redirect or playlist line like that should still take the service down. Your TV's Node may behave differently. Could you catch those too and answer 502, or skip the bad playlist line?
  2. The README still says sportstv is untried on a TV, so it needs your new result.

No worries about Developer Mode, I'll label it "tested on rooted webOS 10.3 only" and release it as a pre-release. I'll merge #42, #43 and #44 first, then #45 once these are in.

@ArnoldDeRuiter

Copy link
Copy Markdown
Contributor Author

Thanks @professorDeveloper, both are in.

  1. Unparsable URLs: confirmed, http://[bad/x throws ERR_INVALID_URL here too (Node 20). url.parse is now inside the try, and redirect and playlist URLs go through a small resolve that returns null instead of throwing. A bad target or redirect answers 502; a playlist line with an unparsable URI (segment or URI="...") is dropped and the rest of the playlist plays. Tests cover all three and that the relay keeps serving afterwards.
  2. README: the sources section now has the sportstv result (native 1080p, no relay or hls.js).

npm test 168/168, npm run test:browser 99/99.

…os-native-relabel

# Conflicts:
#	webos/README.md
#	webos/js/lib/providers.js
@professorDeveloper

Copy link
Copy Markdown
Owner

Thanks, I just read through it and it all looks good. I had resolved the same conflict locally and ended up with exactly the same files as your merge, so I dropped my copy. CI is green too.

One tiny thing for later, no need to hold this up for it: when a bad segment line gets dropped, its #EXTINF stays behind in the playlist.

I'll merge #45 and put it out as a pre-release, labelled as tested on rooted webOS 10.3 only. Thanks so much for all of this, it's been a huge help.

@professorDeveloper professorDeveloper left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's both of them. I read through the changes and they look good.

#42, #43 and #44 are merged now, which left #45 with a small conflict in the README and providers.js. I fixed it with a merge commit on your branch, and kept your relabel: true and the new README text. Your commits are untouched, but please pull before you push anything else.

One tiny thing for later, it doesn't need to hold this up: when a bad segment line gets dropped, its #EXTINF stays behind in the playlist.

I'll merge #45 once CI is green and release it as a pre-release, labelled as tested on rooted webOS 10.3 only. Thanks so much for all of this, it's been a huge help.

@professorDeveloper

Copy link
Copy Markdown
Owner

@ArnoldDeRuiter Thanks for helping )

@professorDeveloper
professorDeveloper merged commit cc8872c into professorDeveloper:integrating-apple-tv Nov 6, 2026
1 check passed
@ArnoldDeRuiter

Copy link
Copy Markdown
Contributor Author

@professorDeveloper Thanks for making the WebOS release possible so swiftly! Glad to help.

professorDeveloper added a commit that referenced this pull request Nov 10, 2026
* Integrating Apple TV (tvOS); Android TV improvements

Apple TV: new native SwiftUI app under apple-tv/ (XcodeGen project, 53 Swift files, PrivacyInfo, CI + Release workflows).
Android TV: profiles (ProfileDatabaseProvider), continue-watching (EpisodeProgress), remote seek steps, search result diffing; torrentserver rebuilt 16 KB page-aligned for Android 15.

* i18n: English base for profile strings, add uz/ru translations

The new profile_* strings landed in values/ as Uzbek; move them to English in the base and add full uz and ru translations so the required locales pass check_strings.py.

* Android TV: dub and other audio languages are offered as servers

Every server-source episode was asked for "sub", so a dub was never
reachable on TV. Each language an episode lists is now resolved and offered
as its own server (Sub, Dub, a voice name), and the picked one is kept for
the next episode. Movies in more than one language are resolved the same
way. Quality lists that a provider files as languages are left alone.

* Apple TV: focused shelf card scrolls into view; Profiles reachable by Up

Moving between shelves focuses the remembered card from code, which does not
scroll: the card could be focused off screen. The Profiles button sits at the
far right with nothing under it, and Up from the first row went past it.
Both failed the UI tests.

* Apple TV: scroll a shelf's own row to its focused card

The outer reader's scrollTo only moves the vertical scroll view, so a
remembered card off the right edge stayed off screen. Each shelf now scrolls
itself when one of its cards takes focus. The UI tests' focus walker logs
where focus is at each step, so a walk that cannot reach its target says why.

* Apple TV: Profiles button built like the other header buttons

Focus reaches the button from the first row, but nothing reported it as
focused, unlike the header buttons built from SozoActionLabel. The Up
override added earlier had no effect and is gone. The UI tests now dump the
screen when no element reports focus or a focused card is off screen.

* Apple TV UI tests: wait out a focus move; check against the window

The focus walker pressed Down whenever no element reported focus, which is
also the state for a moment after every move while the scroll view follows.
Up from Account reached My library and Down took it straight back, so
Profiles was never reached. It now waits for focus to settle first.

The shelf test checked the focused card against app.frame, which is empty on
tvOS, so it failed with the card on screen. It uses the window now.

The Profiles button goes back to how it was: it was never the cause.

* Apple TV UI tests: find a focused button the any-element query misses

With My library focused, the query over all elements found nothing even
after waiting, and the walker pressed Down, back to Account. It now also asks
the buttons query, and when neither answers it repeats its last move instead
of always pressing Down.

* Android TV: the player plays on past episode 100

The player holds one 100-episode part of a series. At its last episode it
showed the end card, Next said "this is the last episode", and the episode
list stopped at 100, so One Piece and any long series looked like it ended
there. Past either end of a part the player now loads the next or the
previous part and plays on, the up-next card announces the first episode of
the next part, and history records the part actually playing.

* Reviewing adapter

* API address: encoded the way the phone app does it

* CI: run the 218 tests that were already written, and stop paying twice for tvOS

app/src/test holds 218 test methods across 36 Kotlin files — the watch-party
wire format, CloudStream extension parsing, AniList matching, history sync,
the player's source selection and auto-advance — and CI ran none of them. It
ran check_strings.py and assembleDebug, so a green check meant the resources
merged and the app compiled, which reads like a much larger claim than it is.
The suite takes eight seconds warm.

tvos-ci.yml carried a paths filter on push but no branch filter, next to a
pull_request trigger with the same paths, so every push to a branch with a PR
open booted a tvOS simulator and ran the whole UI suite twice. On 2 November
that was 21m01s and 18m21s on the same commit, on a macos runner billed at ten
times the Linux rate.

Also: a concurrency group, so pushing three times in ten minutes no longer
queues three full Gradle builds and waits for all of them, and per-job
timeouts.

* Apple TV CI: stop asking the hierarchy for a viewport it no longer reports

"Apple TV CI" has been red since 30 October on one test,
testLongShelvesMoveVerticallyAndReturnToHorizontalPosition, and not because
anything in the app broke. The assertion asked whether the focused title's
frame intersects app.windows.firstMatch.frame. The old comment here already
knew that app.frame is empty on tvOS; on the macos-26 runner the window
element's frame became empty as well, and an empty rect intersects nothing —
so the check failed on a title that was plainly on screen. Run 41400672636
says so in its own failure message: /title/709 at (1488.05, 881.5, 293.89,
492.0), comfortably inside tvOS's 1920x1080 points.

The claim is worth keeping — a shelf that does not scroll leaves focus on
something nobody can see — so it is still asserted, against the window's
frame while the window still reports one and against the fixed point size
tvOS renders at otherwise. A frame of zero on the focused element itself is
now its own failure with its own message, rather than being folded into an
intersection that silently cannot succeed.

Not run here: there is no tvOS runtime on this machine (xcrun simctl list
runtimes shows none), so this is reasoned from the run log and parse-checked
only. CI is the proof.

* Android TV: small fixes for watch party, Live TV, Home View All, CAs and History (#35)

* Android TV: a watch party survives an HDR or HDMI mode switch

WatchPartyActivity declared no configChanges, so a uiMode, density or screen change recreated it, and onDestroy leaves the room, releases the player and stops the proxy. It now declares the same set as the other players, and the players comment sits above it again.

* Live TV: drop the Adlt tab, and do not crash on a bookmarked channel with no stream

The tab played two hard-coded streams whose tokens expired in 2025, and one token carried a third party's peers.tv session. The Bookmarks grid indexed iptvUrls[0] without a check; it now shows the same no-stream toast the Live TV grid does.

* Home: no View All card on a section that has nowhere to go

A section without viewAll was given the slug "::", so its View All card paged GET /contents/ or getCategory("") and landed on an empty grid. Such sections now carry no slug, and the card is only added when there is one.

* Trust user-installed CAs in debug builds only

Release builds trusted any user-added CA, so one could intercept the app's own backend traffic, device-auth tokens included. Cleartext stays allowed for http sources.

* History: tie the sync and clear jobs to the view, not the fragment

They ran on the fragment's lifecycleScope and wrote to the binding, so after onDestroyView they could touch a dead view, and a back-stack return started a second job alongside.

* History: finish a clear and its sync even if the page goes away mid-clear

The clear now runs on the page's view scope, so a view torn down between the tombstone and the delete could leave the tombstone without the follow-up sync. Running it on viewModelScope and joining keeps it whole.

* Stop tracking the release APK, IDE state and a stray subtitle file (#34)

The 45 MB app-release.apk grew history with every rebuild while the README
said APKs are not hosted here; release.yml builds and ships it instead.
.idea and .idea_backup were per-machine state. .gitignore now keeps them
out, except .idea/codeStyles, which carries the shared Kotlin/XML style.
APKs under src/test/resources stay addable as test fixtures. History is
left as it is.

The README still described an AniList-only anime client. It now covers the
Android TV and Apple TV apps, how to build them and the four workflows.
The vendored AARs get a note with their origin and SHA-256.

* Android TV release: test, build once, tag, publish to the CDN and updater (#33)

* CI: callable from the release, and quiet for Apple TV-only changes

The Android TV release now runs the same string check and unit tests before it
builds, so ci.yml accepts workflow_call with an input to skip the debug
assemble. The concurrency group includes the workflow name, so a push to
master can no longer cancel the tests a release is waiting on. Apple TV-only
changes have their own CI and no longer trigger this one.

* Android TV release: test, build, then tag and publish to the CDN

The release ran on dispatch and on v* tags, cancelled itself mid-way, pushed
the version bump before knowing the APK would build, and left the CDN, the
in-app updater and the GitHub Release to be done by hand.

It now runs only on dispatch from the default branch, queues instead of
cancelling, refuses a versionCode that is not higher than the one published
at /api/app-version, runs the unit tests and string check first, and pushes
the bump commit and tag only after the APK built and verified. A publish job
uploads the APK to R2 through the backend with SOZO_RELEASE_TOKEN, creates
the download row, and optionally updates the androidtv updater row; without
the token it warns and skips. The GitHub Release (draft by default) carries
the APK and SHA256SUMS. Only the tagging job gets contents: write, and the
actions in the signing job are pinned to commit SHAs.

* Android TV release: match the backend token rules, and tag code-only builds

The backend refuses a storeUrl sent with the release token, so the updater
always sends storeUrl null instead of copying the row's value; otherwise a
storeUrl set in the admin panel would fail every publish after the APK and
tag had already shipped.

A code-only bump (or none) on an already released name now tags
v<name>-<code> instead of failing on the existing tag. Explicit versions
must be numbers separated by dots, the version guard honours
skip_version_guard when the API base cannot be decoded, and the deliver
job gets a timeout.

* Apple TV: release to TestFlight from Actions (#32)

* Apple TV: add the wide Top Shelf image

App Store Connect expects a Top Shelf Image Wide (2320x720, 4640x1440 @2x) next to the standard one. It is the existing shelf art padded with its own flat #141414 background, so the wordmark stays centred and nothing is stretched.

* Apple TV release: ready for the first TestFlight upload

Apple credentials are not in place yet, so the release has to fail readably and then need nothing but secrets and a dispatch. A Linux preflight lists every missing secret by name before any macOS minutes are spent. The build number defaults to the latest App Store Connect build + 1 (run number if the API query fails), a successful upload is tagged tvos-<version>-<build>, and waiting for processing and adding to an internal group run on Linux. Telegram reports the outcome. Xcode is pinned by input, Homebrew downloads are cached, and CI fails if xcodegen changes committed files.

* Apple TV release: catch build number mistakes before archiving

A wrong build number is only rejected by App Store Connect after about 40
macOS minutes. An upload now stops when the latest build cannot be read
instead of guessing the run number, the automatic number also counts
tvos-* tags so a build that is not listed yet is not reused, and preflight
rejects a manual number that is not above the latest build of that version
and a malformed team ID.

Also: shorter JWT lifetime for clock skew, Xcode version passed through env,
tests for the App Store Connect client with the API mocked, and a clearer
xcodegen drift error since CI's xcodegen is unpinned.

* Android TV: strip kkphim's ads and sign asilmedia's fayllar1 files (#37)

* Android TV: take kkphim's ads out and sign asilmedia's fayllar1 files

The backend sends a dropSegments rule for kkphim and a signer for
asilmedia's fayllar1 files, and the TV dropped both on the way to the
player: kkphim played its spliced ads, and fayllar1 was asked for the
bare file, which it refuses. Both now reach the player as they do on
the phone. A source with a rule goes through the local proxy, which
strips the matching segments from each media playlist; a signed file
is signed on the device, with the player's own User-Agent, before it
plays. Ported from hls_segment_filter.dart and url_signer.dart.

* Android TV: sign fayllar1 files each time they start, and let kkphim open externally again

The file was signed once, when the source was built, and the signed URL
was kept. A retry after the token expired sent the same dead token, so
a long film that failed after a pause could not be resumed without
picking the source again. The source now keeps the unsigned file and
the player signs it on every start, as the phone does; the external
player and downloads sign it when they are opened. History no longer
stores a token bound to this device's IP and User-Agent.

The ad rule no longer marks kkphim as needing the proxy, which had
stopped those streams from opening in an external player. The player
still routes them through the proxy to strip the ads.

* Apple TV: relay image-wrapped HLS segments through the backend (#36)

* Apple TV: relay image-wrapped HLS segments through the backend

Streams on the /stream/*.m3u8 route serve their TS segments as tiktokcdn
.image files with a PNG prefix, which AVPlayer cannot play. Mobile and
Android TV rewrite those segment URLs to /api/contents/media-segment;
tvOS had no rewrite at all.

The playlists now load through an AVAssetResourceLoaderDelegate on a
custom scheme, which fetches them on the device with the source headers
(their tokens are bound to its address) and rewrites allowlisted
segments to the relay. Other sources keep the existing direct path.

* Apple TV: keep source headers on direct segments of relayed streams

Segments outside the relay allowlist, EXT-X-KEY URIs and init segments
are fetched by AVPlayer itself, so without the asset header option they
lost Referer/Origin and any header-checked CDN that played before would
now fail. Mobile and Android TV proxy them with the source headers.

The loader also finishes its requests on the queue it was registered on
rather than the URLSession delegate queue.

* Apple TV: explain failed streams with a working Retry, focus Play, remove favourites (#39)

* Apple TV player: explain a failed stream and offer Retry

The player only saw item.status and a startup timeout, so a long stall
went unnoticed and a failure showed AVFoundation's raw message with a
single button. It now also watches FailedToPlayToEndTime, stalls that
last 30 seconds and the error log, maps them to a reason the viewer can
act on (offline, refused or expired link, gone, unsupported format), and
offers Retry, Choose another source and Close. Retry is handed back to
the caller so the stream is rebuilt through the normal loading path.

* Apple TV detail: focus Play or the episodes, and let favourites be removed

Focus landed on "Add to favorites" because the save row sits above the
playback controls. The screen now focuses Play film, or the resumed or
first episode, once loading finishes. The favourites button reads the
profile's saved state, shows Remove when the title is already saved and
calls DELETE /auth/favorites. The detail screen also wires the player's
Retry to present the same stream again from the last position.

* Apple TV: survive slow sources, throttling and a deleted profile

The backend gives /contents/media 60 s to resolve a slow provider, but
every request here gave up after 30 s of silence. Media now waits 75 s;
everything else keeps 30 s.

Backend messages are Uzbek and mostly carry no code, so they no longer
reach the screen: the error code, then the HTTP status, picks an English
message, and a body that does not decode says so instead of Foundation's
text. A 429 or 503 GET with a short Retry-After is retried once after
that wait; a longer one is shown as "try again in N seconds".

Device-link polling stopped for good on the first failed poll. It now
backs off exponentially on network errors, 429, 503 and 5xx, honours
Retry-After, and gives up only on permanent errors or code expiry. The
"denied" branch is gone: pollToken only returns pending, expired or
approved.

A PROFILE_NOT_FOUND reply drops the active profile, which brings back
the picker, and reloads the list.

"Choose another source" and playing a film no longer reuse the first,
possibly expired, signed URLs: episodes call contents/media again and
inline film sources are fetched again from contents/episodes, since they
have no media ref. Continue watching skips a malformed row instead of
losing the whole rail.

* Apple TV: keep the active profile when only a managed profile is gone

The backend returns PROFILE_NOT_FOUND both for a missing active profile and for
a missing target of a profile edit, delete or PIN check. Reload the listing
instead of assuming the active one was deleted, as the phone app does.

Switching sources falls back to the earlier candidates when the fresh
resolution fails, and films refetch their inline sources only on a switch.
A string episodeIndex in history is read like a string episodeNumber.

* Apple TV player: retry fetches a fresh link instead of replaying the old one

Retry replayed the same URL and headers, so a stream refused because its
signed link expired just failed again. Retry now resolves the title again
(a film refetches its sources) and plays the same source at the kept position.

A mapped error now outranks the error log, and only a log entry from the last
few seconds is used, so a segment AVPlayer already recovered from no longer
explains a later network loss. "Cannot Open" (-11828) is reported as a blocked
source, as on mobile. A stall alert no longer fires after playback recovered.

* Apple TV: survive slow sources, throttling and removed profiles (#38)

* Apple TV: survive slow sources, throttling and a deleted profile

The backend gives /contents/media 60 s to resolve a slow provider, but
every request here gave up after 30 s of silence. Media now waits 75 s;
everything else keeps 30 s.

Backend messages are Uzbek and mostly carry no code, so they no longer
reach the screen: the error code, then the HTTP status, picks an English
message, and a body that does not decode says so instead of Foundation's
text. A 429 or 503 GET with a short Retry-After is retried once after
that wait; a longer one is shown as "try again in N seconds".

Device-link polling stopped for good on the first failed poll. It now
backs off exponentially on network errors, 429, 503 and 5xx, honours
Retry-After, and gives up only on permanent errors or code expiry. The
"denied" branch is gone: pollToken only returns pending, expired or
approved.

A PROFILE_NOT_FOUND reply drops the active profile, which brings back
the picker, and reloads the list.

"Choose another source" and playing a film no longer reuse the first,
possibly expired, signed URLs: episodes call contents/media again and
inline film sources are fetched again from contents/episodes, since they
have no media ref. Continue watching skips a malformed row instead of
losing the whole rail.

* Apple TV: keep the active profile when only a managed profile is gone

The backend returns PROFILE_NOT_FOUND both for a missing active profile and for
a missing target of a profile edit, delete or PIN check. Reload the listing
instead of assuming the active one was deleted, as the phone app does.

Switching sources falls back to the earlier candidates when the fresh
resolution fails, and films refetch their inline sources only on a switch.
A string episodeIndex in history is read like a string episodeNumber.

* Apple TV: name source outages, and test the messages the app now shows

Since the error text comes from the code and status rather than the server's Uzbek message, the UI tests waited for fixture strings that never appear. Source and upstream codes now read as an unavailable source; the retry tests expect the 503 wording.

* Apple TV UI tests: the notifications retry message, and a settled shelf frame

The notifications retry waited for the fixture's text, which the app no longer shows. The long-shelf check read the focused title's frame mid-scroll and reported a later, on-screen reading; it now waits for the frame to settle and asserts on that one value.

* Decrypt KissKH's encrypted subtitle cues on Android TV and Apple TV (#40)

* Decrypt KissKH's encrypted subtitle cues on Android TV and Apple TV

KissKH's .txt1 subtitles are SRT files whose cue text lines are each
AES-128-CBC ciphertext, so viewers saw base64 instead of captions. The
backend now tags those tracks with a cipher; both players carry it from
the media payload and open each cue text line after download, before
parsing. A key that opens no line or an unknown algorithm fails the
track instead of showing ciphertext.

* Carry the KissKH subtitle cipher through ServerHost and refuse keys that open few cues

translateMedia rebuilt each subtitle from a fixed set of keys and dropped
cipher, so on Android TV KissKH tracks still reached the player as base64.
A wrong AES key still unpads cleanly on about one line in 256, so a cue now
only counts as opened when it is strict UTF-8, and a track fails unless at
least half its cues open. Decrypted lines keep their trailing \r.

* Add an LG webOS TV app (#41)

* Add an LG webOS TV app

A plain ES5 web app for webOS TV 4.x and newer, with no build step. It browses,
searches and plays the nine allowlisted server sources with the remote or the
Magic Remote pointer. Not yet run on a real TV.

webos.yml runs the unit and ES5 checks and keeps the ipk as an artifact.

* Give the webOS app a release workflow and skip Android CI for it

Android jobs took about ten minutes on changes that only touch webos/.
CI artifacts expire after 14 days, so a manual workflow now publishes the ipk
as a pre-release in this repository.

* Let vidapi fall back to hls.js on webOS (#42)

* Start hls.js from a 5 Mbps bandwidth estimate (#43)

* webOS: subtitle timing offset in half-second steps (#44)

* Add half-second subtitle timing offset to the webOS player

* Move subtitle timing to compact chips beside the offset

* webOS: play vidapi natively through a loopback relay (#45)

* Let vidapi fall back to hls.js on webOS

* Play vidapi natively on webOS through a loopback relay that fixes segment content types

* Restrict the relay to Sozo and public hosts, pipe segments, abort redirected requests

* Make the relay service private

* Answer 502 when a relay request cannot be made, such as a redirect to a non-http scheme

* Percent-encode non-ASCII relay paths and normalise IPv6 before the public-address check

* Answer 502 for unparsable relay targets and redirects, drop unparsable playlist lines

* Record sportstv playing natively on webOS 10.3 in the README

* Relay API-declared headers on webOS and allow seven more sources, with mkv audio and subtitle choice (#46)

---------

Co-authored-by: professorDeveloper <108933534+professorDeveloper@users.noreply.github.com>
Co-authored-by: Arnold de Ruiter <187004+ArnoldDeRuiter@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants