Renames Sources/PlumTV→TVAnarchy and PlumTVCore→TVAnarchyCore (the rename the auto-commit service couldn't stage — it git-add'd the old, now-gone paths and aborted every cycle), and commits the accumulated work: - Library: black-built index fast path (LibraryIndex + scanFromIndex) with NFS-walk fallback; incremental --add on download-complete; mtime staleness gate; loose-file series-collapse fix; determinate scan/index progress. - Cover art: keyless TVmaze cartoon-vs-live-action disambiguation (type/year). - Player: sleep timer (timed + end-of-episode); visibility-gated polling. - Home: Continue Watching cover art + live refresh; Recently Added; adult gate. - Logs: multi-line selection + copy; truncated giant tx-list errors. - Hover previews (opt-in) via black ffmpeg + scp. Also gitignores foreign project trees (governor/mcp/fleet/recommender) that sit in this directory but belong to their own repos. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
29 lines
1.3 KiB
Swift
29 lines
1.3 KiB
Swift
import Foundation
|
|
|
|
/// JSON snapshot cache of the library at `~/.local/state/tv-anarchy/library.json`.
|
|
/// A plain Codable file (a few-hundred-show library fits in memory trivially) —
|
|
/// the offline-browsable source of truth when ~/media / black are unreachable.
|
|
public enum LibraryStore {
|
|
public static func snapshotURL() -> URL {
|
|
FileManager.default.homeDirectoryForCurrentUser
|
|
.appendingPathComponent(".local/state/tv-anarchy/library.json")
|
|
}
|
|
|
|
public static func load() -> LibrarySnapshot? {
|
|
guard let data = try? Data(contentsOf: snapshotURL()) else { return nil }
|
|
let dec = JSONDecoder()
|
|
dec.dateDecodingStrategy = .iso8601
|
|
return try? dec.decode(LibrarySnapshot.self, from: data)
|
|
}
|
|
|
|
public static func save(_ snapshot: LibrarySnapshot) {
|
|
let url = snapshotURL()
|
|
try? FileManager.default.createDirectory(at: url.deletingLastPathComponent(),
|
|
withIntermediateDirectories: true)
|
|
let enc = JSONEncoder()
|
|
enc.outputFormatting = [.prettyPrinted, .withoutEscapingSlashes]
|
|
enc.dateEncodingStrategy = .iso8601
|
|
guard let data = try? enc.encode(snapshot) else { return }
|
|
try? data.write(to: url, options: .atomic)
|
|
}
|
|
}
|