A CarPlay scene beside the phone's: In Progress, Unread and Shows as
CPListTemplates from ipx's API, read with the player's credentials, and
a pick played through the same Playback, so it resumes from the saved
place, saves as it goes and marks read at 90%. Now Playing is the
system's template over Playback's now-playing info.
When the car starts a different episode the page is sent
{t:"replaced"} and closes its player bar. Left open, the bar would have
gone on as the old episode while the host's clock belonged to the new
one, saving that time and marking the wrong item read.
The badge's fetch moves into API.get, which CarPlay shares. Build 13.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
24 lines
1.0 KiB
Swift
24 lines
1.0 KiB
Swift
import Foundation
|
|
|
|
/// Reading ipx without the page: the badge and CarPlay (#420), which has no web view. Signed in
|
|
/// as the player is, by the credentials or else the cookies the web view left (CookieBridge).
|
|
enum API {
|
|
private static let session: URLSession = {
|
|
let cfg = URLSessionConfiguration.default
|
|
cfg.httpCookieStorage = .shared
|
|
cfg.timeoutIntervalForRequest = 20
|
|
return URLSession(configuration: cfg)
|
|
}()
|
|
|
|
/// The body of a 200, or nil: not signed in, no server, no connection.
|
|
static func get(_ path: String) async -> Data? {
|
|
guard let url = Server.resolveForPlayer(path) else { return nil }
|
|
var req = URLRequest(url: url)
|
|
req.setValue("application/json", forHTTPHeaderField: "Accept")
|
|
Credentials.headers.forEach { req.setValue($1, forHTTPHeaderField: $0) }
|
|
guard let (data, resp) = try? await session.data(for: req),
|
|
(resp as? HTTPURLResponse)?.statusCode == 200 else { return nil }
|
|
return data
|
|
}
|
|
}
|