Create a channel and More, refined (design v3 with Paul's notes)
Start quick (the Director builds it from a line, or a collection by name) or custom. One search for titles, collections, networks and genres. A collection page with Add all, Refine by type and age, and a note while it's still being read. The day in folding parts with how full each is, star and move in place. Review where style, hours and dates can change, the week in hours, balance, clashes, and two endings that never interrupt: Create & watch next on <room>, or Create channel. The action bar stays at the foot; long lists scroll and picks are kept. More: faces for who's watching, the Director with a count, channel tiles, and settings as a short list. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -187,6 +187,15 @@ internal class CatalogueStore(context: Context, private val file: File) : Catalo
|
||||
buildList { while (c.moveToNext()) add(ShapeRow(c.getString(0), c.getString(1), c.getString(2), if (c.isNull(3)) null else c.getInt(3), c.getString(4), c.getString(5).split('|').filter { it.isNotBlank() }.toSet())) }
|
||||
}
|
||||
}
|
||||
/** Networks and studios whose names contain [text], with how many titles each has: for Create's one search. Read only. */
|
||||
@Synchronized fun studiosMatching(text: String, limit: Int = 5): List<Pair<String, Int>> {
|
||||
val q = text.trim().take(60); if (q.length < 2) return emptyList()
|
||||
val counts = HashMap<String, Int>()
|
||||
readableDatabase.rawQuery("SELECT studios FROM items WHERE type IN ('Movie','Series') AND studios LIKE ?", arrayOf("%$q%")).use { c ->
|
||||
while (c.moveToNext()) c.getString(0).split('|').filter { it.contains(q, ignoreCase = true) }.forEach { counts.merge(it, 1, Int::plus) }
|
||||
}
|
||||
return counts.entries.sortedByDescending { it.value }.take(limit).map { it.key to it.value }
|
||||
}
|
||||
/** Films' running times by item, for Smart setup's hours estimate. Read only. */
|
||||
@Synchronized fun runTimes(ids: Collection<String>): Map<String, Long> = ids.distinct().chunked(400).flatMap { chunk ->
|
||||
readableDatabase.rawQuery("SELECT id, runtime_ms FROM items WHERE runtime_ms IS NOT NULL AND id IN (${chunk.joinToString(",") { "?" }})", chunk.toTypedArray()).use { c ->
|
||||
|
||||
@@ -56,7 +56,9 @@ internal class ChannelMaker(
|
||||
/** Your Emby collections, for Browse › From a collection: each one's name, members and whether all of them were read. */
|
||||
val collections: suspend () -> List<LibraryCollection> = { emptyList() },
|
||||
/** Titles by item from the catalogue alone, quickly, for listing a collection. */
|
||||
val rowsOf: suspend (List<String>) -> List<ShapeRow> = { emptyList() })
|
||||
val rowsOf: suspend (List<String>) -> List<ShapeRow> = { emptyList() },
|
||||
/** Networks and studios by name, with their title counts. */
|
||||
val studios: suspend (String) -> List<Pair<String, Int>> = { emptyList() })
|
||||
|
||||
/** One of the library's collections as Orbit read it. [complete] is false when it stopped short of [total]. */
|
||||
internal class LibraryCollection(val name: String, val members: List<String>, val total: Int, val complete: Boolean)
|
||||
|
||||
@@ -62,9 +62,9 @@ internal class HttpsEmbyTransport(internal val deviceId: String = UUID.randomUUI
|
||||
}
|
||||
/** The sign-in headers for this kind of server. */
|
||||
internal fun authHeaders(token: String?): Map<String, String> = when (kind) {
|
||||
ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.85\"") +
|
||||
ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.86\"") +
|
||||
(token?.let { mapOf("X-Emby-Token" to it) } ?: emptyMap())
|
||||
ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.85\"" +
|
||||
ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.86\"" +
|
||||
(token?.let { ", Token=\"$it\"" } ?: ""))
|
||||
}
|
||||
/** One picture from the provider, or nothing. Same fixed origin and no redirects, and failures are never shown or logged. */
|
||||
|
||||
@@ -553,6 +553,7 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
|
||||
} },
|
||||
collections = { withContext(Dispatchers.IO) { readCollections(scheduleStore.collectionsFile()) } },
|
||||
rowsOf = { ids -> withContext(Dispatchers.IO) { catalogue.shapeRows(ids) } },
|
||||
studios = { text -> withContext(Dispatchers.IO) { catalogue.studiosMatching(text) } },
|
||||
runTime = { rows -> rows.takeIf { r -> r.isNotEmpty() && r.all { it.runMs != null } }?.sumOf { it.runMs ?: 0L } },
|
||||
carriedBy = { picks, number -> titlesCarriedBy(picks, scheduledChannels.values.filter { it.number != number }) },
|
||||
create = { asked, shows ->
|
||||
|
||||
@@ -310,6 +310,20 @@ internal object PhoneLink {
|
||||
val (genres, studios) = runBlocking { h.maker.facets() }
|
||||
json(out, 200, JSONObject().put("genres", JSONArray(genres)).put("studios", JSONArray(studios)).put("ratings", JSONArray(RatingGroups.keys.toList())))
|
||||
}
|
||||
// Create's one search (Paul, 7 November 2026: "search could include the collections"): titles, collections, networks
|
||||
// and genres together.
|
||||
"GET /api/search" -> {
|
||||
val q = r.query["q"].orEmpty().trim().take(80)
|
||||
if (q.length < 2) return json(out, 200, JSONObject().put("collections", JSONArray()).put("networks", JSONArray()).put("genres", JSONArray()).put("titles", JSONArray()))
|
||||
val cols = runBlocking { h.maker.collections() }.filter { it.name.contains(q, ignoreCase = true) }.sortedBy { !it.name.startsWith(q, ignoreCase = true) }.take(5)
|
||||
val nets = runBlocking { h.maker.studios(q) }
|
||||
val genres = runBlocking { h.maker.facets() }.first.filter { it.contains(q, ignoreCase = true) }.take(4)
|
||||
val titles = runBlocking { h.maker.search(q) }.take(20)
|
||||
json(out, 200, JSONObject()
|
||||
.put("collections", JSONArray(cols.map { c -> JSONObject().put("name", c.name).put("count", c.members.size).put("total", c.total).put("complete", c.complete) }))
|
||||
.put("networks", JSONArray(nets.map { (n, k) -> JSONObject().put("name", n).put("count", k) })).put("genres", JSONArray(genres))
|
||||
.put("titles", JSONArray(titles.map(::suggestionJson))))
|
||||
}
|
||||
"GET /api/collections" -> {
|
||||
val all = runBlocking { h.maker.collections() }
|
||||
json(out, 200, JSONObject().put("collections", JSONArray(all.map { c -> JSONObject().put("name", c.name).put("count", c.members.size).put("total", c.total).put("complete", c.complete) })))
|
||||
@@ -319,7 +333,7 @@ internal object PhoneLink {
|
||||
val c = runBlocking { h.maker.collections() }.firstOrNull { it.name == r.query["collection"] } ?: return json(out, 404, JSONObject().put("error", "That collection isn't in the library copy yet."))
|
||||
val rows = runBlocking { h.maker.rowsOf(c.members.take(1000)) }
|
||||
json(out, 200, JSONObject().put("complete", c.complete).put("total", c.total).put("found", rows.size).put("items", JSONArray(rows.map { row -> suggestionJson(Suggestion(row.id, row.title, row.year, row.type, "",
|
||||
listOfNotNull(row.genres.take(2).joinToString(", ").ifEmpty { null }, row.rating.ifEmpty { null }).joinToString(" · ").ifEmpty { "In ${c.name}" })) })))
|
||||
listOfNotNull(row.genres.take(2).joinToString(", ").ifEmpty { null }, row.rating.ifEmpty { null }).joinToString(" · ").ifEmpty { "In ${c.name}" })).put("band", ratingBand(row.rating).name) })))
|
||||
} else {
|
||||
val rows = runBlocking { h.maker.browse(r.query["genre"]?.take(60), r.query["studio"]?.take(80), RatingGroups[r.query["rating"]].orEmpty(), r.query["type"]?.takeIf { it == "Movie" || it == "Series" }) }
|
||||
json(out, 200, JSONArray(rows.map { row -> suggestionJson(Suggestion(row.id, row.title, row.year, row.type, "",
|
||||
@@ -340,7 +354,8 @@ internal object PhoneLink {
|
||||
.put("suggestedCore", JSONArray(shape.suggestedCore.toList())).put("notes", JSONArray(shape.notes))
|
||||
.put("suggestedSeason", shape.suggestedSeason?.let { it.toJson().put("label", it.label) } ?: JSONObject.NULL)
|
||||
.put("week", total?.takeIf { it > 0 }?.let { weekLine(it, hoursPerDay) } ?: weekCheck(series, films) ?: JSONObject.NULL)
|
||||
.put("hours", total?.let { it / 3_600_000.0 } ?: JSONObject.NULL))
|
||||
.put("hours", total?.let { it / 3_600_000.0 } ?: JSONObject.NULL)
|
||||
.put("runHours", JSONObject(rows.filter { it.runMs != null }.associate { it.id to it.runMs!! / 3_600_000.0 })))
|
||||
}
|
||||
"POST /api/clashes" -> {
|
||||
val o = runCatching { JSONObject(r.body) }.getOrNull() ?: return json(out, 400, JSONObject())
|
||||
|
||||
@@ -39,7 +39,7 @@ internal class SecureMediaDataSource(private val session: EmbySampleSession) : B
|
||||
next.instanceFollowRedirects = false
|
||||
next.connectTimeout = 10_000
|
||||
next.readTimeout = 20_000
|
||||
next.setRequestProperty("User-Agent", "OrbitTV/0.108.85")
|
||||
next.setRequestProperty("User-Agent", "OrbitTV/0.108.86")
|
||||
next.setRequestProperty("Accept-Encoding", "identity")
|
||||
session.mediaHeaders(address).forEach { (key, value) -> next.setRequestProperty(key, value) }
|
||||
if (dataSpec.position != 0L || dataSpec.length != C.LENGTH_UNSET.toLong()) {
|
||||
|
||||
Reference in New Issue
Block a user