summaryrefslogtreecommitdiff
path: root/server/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'server/cmd')
-rw-r--r--server/cmd/listend/main.go28
1 files changed, 27 insertions, 1 deletions
diff --git a/server/cmd/listend/main.go b/server/cmd/listend/main.go
index 8620d0d..6a76f08 100644
--- a/server/cmd/listend/main.go
+++ b/server/cmd/listend/main.go
@@ -574,6 +574,7 @@ func (w *worker) rederiveAds() {
log.Printf("re-deriving %q: %v", e.Title, err)
continue
}
+ w.publishWordBreaks(e, found)
changed++
}
}
@@ -595,6 +596,29 @@ func sameCandidates(left, right []transcript.Candidate) bool {
}
/*
+publishWordBreaks turns what the words found into stretches the phone will actually seek past.
+
+The only place anything read out of a transcript reaches playback. Everything else in this
+pipeline produces candidates to look at; transcript.Publishable decides which of them are fit to
+act on, and refuses the rest with a reason rather than silently dropping them.
+
+Kept in their own field so the ad scan, which rewrites its own list from scratch on every
+detection pass, cannot wipe them -- and so that which detector found a break stays answerable.
+*/
+func (w *worker) publishWordBreaks(e *store.Episode, found []transcript.Candidate) {
+ fit, why := transcript.Publishable(found, e.DurationMs, e.DeclaredDurationMs)
+ e.WordAdsRefused = why
+ e.WordBreaks = nil
+ for _, c := range fit {
+ e.WordBreaks = append(e.WordBreaks, store.Break{
+ StartMs: c.StartMs,
+ EndMs: c.EndMs,
+ Kind: string(skips.KindAd),
+ })
+ }
+}
+
+/*
adsIn works out which stretches of a recognised episode are advertising.
By subtraction where the publisher's ad-free master is held, and by reading the ad copy where it
@@ -781,6 +805,7 @@ func (w *worker) refetchOne(
if err := w.transcripts.Put(held); err != nil {
return nil, second.DurationMs, err
}
+ w.publishWordBreaks(e, held.Ads)
return held.Ads, second.DurationMs, nil
}
@@ -791,10 +816,11 @@ Newest first: an episode about to be played is worth the work before one from th
catalogue.
*/
func (w *worker) pendingRefetch() []*store.Episode {
+ now := time.Now().Unix()
var pending []*store.Episode
for _, show := range w.state.Shows() {
for _, e := range show.Episodes {
- if !e.NeedsRefetch() {
+ if !e.NeedsRefetch(now) {
continue
}
// Without a length gap nothing was inserted, so a second fetch would be the same