You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Generated Chapters] Refresh an episode's generated transcript flag when it's opened - #6336
Episodes added by the hourly refresh always have has_generated_transcript = false, because the refresh payload doesn't include that field. The flag was only updated when you opened the podcast page. Until then, the generated transcript wasn't added for the episode, so the Transcript button stayed disabled and generated chapters didn't show.
Now, when show notes are processed for an episode on a screen the user opened (player, shelf, Notes, episode details, bookmarks), and the episode's flag is false, the app re-reads the full podcast JSON and sets the flag for every episode the server marks as having a generated transcript. The generated transcript row is then added in the same pass.
Only for podcast episodes published in the last 60 days (the server only generates transcripts for those).
At most once per podcast every 30 minutes. A failed fetch (network or HTTP error) can be retried right away.
Failures are logged and ignored.
Background show notes downloads (auto-download) never trigger it.
Cost: The Daily's full podcast JSON is 343 KB over the wire (gzip, CloudFront cached; 2.1 MB decoded). OkHttp requests gzip transparently. With the 30-minute throttle that's at most one fetch per podcast per 30 minutes, and only while a recent episode's flag is still false.
Needs a debug build (staging), a device or emulator, and sqlite3 on your computer (macOS ships one). Signed out is fine.
Setup
./gradlew :app:installDebug
PKG=au.com.shiftyjelly.pocketcasts.debug
PODCAST=4eb5b260-c933-0134-10da-25324e2a541d # The Daily on staging
Open the app and follow The Daily. Leave its podcast page.
Make the flag stale (what the hourly refresh leaves behind)
Pull the database, reset the flag and transcripts for The Daily, and push it back:
adb shell am force-stop $PKG
rm -f pocketcasts pocketcasts-wal pocketcasts-shm
forfin pocketcasts pocketcasts-wal pocketcasts-shm;do adb exec-out run-as $PKG cat databases/$f>$f;done
sqlite3 pocketcasts " UPDATE podcast_episodes SET has_generated_transcript = 0 WHERE podcast_id = '$PODCAST'; DELETE FROM episode_transcript WHERE episode_uuid IN (SELECT uuid FROM podcast_episodes WHERE podcast_id = '$PODCAST'); PRAGMA wal_checkpoint(TRUNCATE);"
adb push pocketcasts /data/local/tmp/pocketcasts
adb shell run-as $PKG sh -c "'rm -f databases/pocketcasts-wal databases/pocketcasts-shm && cp /data/local/tmp/pocketcasts databases/pocketcasts'"
adb shell rm /data/local/tmp/pocketcasts
Check the newest episodes are stale:
sqlite3 pocketcasts "SELECT uuid, title, has_generated_transcript FROM podcast_episodes WHERE podcast_id = '$PODCAST' ORDER BY published_date DESC LIMIT 3;"
✅ has_generated_transcript is 0.
Before: offline
Run adb shell cmd connectivity airplane-mode enable, then start the app.
Go to Filters → New Releases (don't open the podcast page) and play the newest The Daily episode. Open the full-screen player.
Open ⋮ in the player shelf. ✅ Transcript is disabled.
Run adb shell cmd connectivity airplane-mode disable and adb shell am force-stop $PKG, then start the app and open the full-screen player again.
✅ Logcat shows:
I/OkHttp: --> GET https://podcast-api.pocketcasts.net/mobile/podcast/full/4eb5b260-c933-0134-10da-25324e2a541d
I/BgTask: Refreshed generated transcript flags for podcast 4eb5b260-…, N episodes have one
Open ⋮ in the player shelf. ✅ Transcript is enabled and opens the generated transcript.
Optional, check the database:
adb shell am force-stop $PKG
rm -f pocketcasts pocketcasts-wal pocketcasts-shm
forfin pocketcasts pocketcasts-wal pocketcasts-shm;do adb exec-out run-as $PKG cat databases/$f>$f;done
sqlite3 pocketcasts "SELECT p.uuid, p.has_generated_transcript, t.url, t.is_generated FROM podcast_episodes p LEFT JOIN episode_transcript t ON t.episode_uuid = p.uuid WHERE p.podcast_id = '$PODCAST' ORDER BY p.published_date DESC LIMIT 3;"
✅ The episode you played has flag 1 and a …/generated_transcripts/…/<episode>.vtt row with is_generated = 1.
No repeat fetch
Close and reopen the full-screen player, then play another recent The Daily episode.
✅ No new mobile/podcast/full request in logcat. The flags are already 1, and the same podcast isn't fetched again within 30 minutes.
Unit tests (cover the 30-minute throttle, retry after a failed fetch, the 60-day window and the background download skip)
The approach works. It runs off the UI path in ApplicationScope, only sets the flag (never clears it) and is throttled per podcast. There's one blocking issue: an HTTP error response is throttled as if the refresh had succeeded, which breaks the "failed fetch can be retried right away" behaviour this PR describes.
Blocking
modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/shownotes/GeneratedTranscriptFlagRefresher.kt:54: If the server returns 5xx/429/404, Transcript stays disabled for that podcast for 30 minutes, because getPodcastResponse doesn't throw on non-2xx and lastRefreshes is recorded anyway. Only record the refresh when response.isSuccessful && body != null. [Generated Chapters] Refresh an episode's generated transcript flag when it's opened #6336 (comment)
Non-blocking
modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/shownotes/GeneratedTranscriptFlagRefresher.kt:35: One global Mutex makes full-podcast fetches for different podcasts wait on each other, so one slow fetch delays show notes processing for unrelated podcasts. Use a lock per podcastUuid. [Generated Chapters] Refresh an episode's generated transcript flag when it's opened #6336 (comment)
I reviewed the two commits pushed since my last review (bd4084f background download skip, 834836d throttle only on success and lock per podcast) and found no new issues. Both earlier findings are fixed: a non-2xx or empty response now returns before lastRefreshes is set, which a new 503 test covers, and the global Mutex is now one lock per podcast. downloadToCacheShowNotes (auto-download) no longer triggers the fetch. The background path still reads the flag from the database, so it won't drop a generated transcript row that a user-opened screen already added.
Version 8.26 has now entered code-freeze, so the milestone of this PR has been updated to 8.27.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Episodes added by the hourly refresh always have
has_generated_transcript = false, because the refresh payload doesn't include that field. The flag was only updated when you opened the podcast page. Until then, the generated transcript wasn't added for the episode, so the Transcript button stayed disabled and generated chapters didn't show.Now, when show notes are processed for an episode on a screen the user opened (player, shelf, Notes, episode details, bookmarks), and the episode's flag is false, the app re-reads the full podcast JSON and sets the flag for every episode the server marks as having a generated transcript. The generated transcript row is then added in the same pass.
Fixes PCDROID-817 https://linear.app/a8c/issue/PCDROID-817
Testing Instructions
Needs a debug build (staging), a device or emulator, and
sqlite3on your computer (macOS ships one). Signed out is fine.Setup
./gradlew :app:installDebug PKG=au.com.shiftyjelly.pocketcasts.debug PODCAST=4eb5b260-c933-0134-10da-25324e2a541d # The Daily on stagingMake the flag stale (what the hourly refresh leaves behind)
sqlite3 pocketcasts "SELECT uuid, title, has_generated_transcript FROM podcast_episodes WHERE podcast_id = '$PODCAST' ORDER BY published_date DESC LIMIT 3;"has_generated_transcriptis0.Before: offline
adb shell cmd connectivity airplane-mode enable, then start the app.After: online
adb shell cmd connectivity airplane-mode disableandadb shell am force-stop $PKG, then start the app and open the full-screen player again.1and a…/generated_transcripts/…/<episode>.vttrow withis_generated = 1.No repeat fetch
mobile/podcast/fullrequest in logcat. The flags are already1, and the same podcast isn't fetched again within 30 minutes.Unit tests (cover the 30-minute throttle, retry after a failed fetch, the 60-day window and the background download skip)
Screenshots or Screencast
Logcat on a staging debug build, after opening the player:
App database before and after opening the player:
Checklist
./gradlew spotlessApplyto automatically apply formatting/linting)modules/services/localization/src/main/res/values/strings.xmlI have tested any UI changes...