feat(guide): Ask the pool for only the guide window the cache keeps #35
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/guide-window"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What was wrong
The pool's
xmltv.php(the pool is our IPTV pool server) sends everything it keeps: 6 hours back and 36 ahead, 3.4 MB gzipped and about 85,000 programmes for the tv3 test login. LiveWire parses all of it and then drops everything outside the window it caches (EpgCachePolicy.downloadWindow). The pool now has aguide_windowfeature that sends only a given window. This is the app side of that contract.What changed
PoolSignals.ktaddsGUIDE_WINDOW, gated the same way asretry,stop,sourcesandevent_info.EpgRepository.ktaddspast_hoursandfuture_hoursto the guide URL when the provider'spool_infolistsguide_windowand the request has a window. A plain Xtream panel, an M3U guide and a request with no window (onboarding) get the full guide as before.EpgCachePolicy.poolGuideRequestturns the parsed window into whole hours counted from the start of the current hour, rounded outward and clamped to the pool's limits (0-6 back, 1-36 ahead).GuideDownload.Loaded.window, used byEpgCache.kt).EpgCachePolicy.poolGuideCoveredworks it out from the response'sDateheader, the pool's clock, not the TV's. So a request the pool clamped, a TV clock that is off, or a request that crosses the hour is stored as the smaller window it really is, andcovers()keeps rejecting requests it can't serve. A narrower window isn't treated as an error.Verified
testDebugUnitTest(617 tests),lintDebugandassembleDebugpass. New tests:EpgCachePolicyTest.kthas the hour rounding, clamping, pool clocks an hour ahead and behind, and a 5,000-case check that the stored window is never wider than what the pool sent.GuideDownloadTest.ktchecks the URL and theDate-based window.EpgGuideWindowTest.ktchecks the gate (feature listed, not listed, plain panel, M3U, no window) and that a clamped window makes a request beyond it download again instead of being served short.past_hours=4&future_hours=21, and the stored window matched the parsed one exactly. Both branches kept the same 73,659 programmes after parsing. Median download plus parse: 4.4 s onmain, 4.2 s here. The Guide and Search were then served from that one download, and an aged entry revalidated with a 304 within the hour.Smaller saving than the contract's table
The contract measured the Guide's window (about 3 back, 14 ahead, 2.4 MB). In practice Home opens first, and its window is 25 hours long (
now - 2h .. now + 12h, plusdownloadWindow's 2 hours before, and 6 hours and the 3-hour TTL after). That is 4 back and 21 ahead: 3.08 MB against 3.40 MB for the full guide, about 9% less. Shortening Home's window would save more: 4 back and 12 ahead is 2.24 MB. That changes what Home's channel info shows, so it isn't in this PR.