feat(podcasts): add an option to purge old episodes

* Record podcast episode plays in ModifiedAt field.

* Added podcast purger.
This commit is contained in:
brian-doherty
2022-11-07 17:29:53 -06:00
committed by sentriz
parent 064bd587a8
commit 85cb0feb5a
5 changed files with 144 additions and 58 deletions

View File

@@ -1,4 +1,5 @@
// Package main is the gonic server entrypoint
//
//nolint:lll // flags help strings
package main
@@ -35,9 +36,10 @@ func main() {
confPodcastPath := set.String("podcast-path", "", "path to podcasts")
confCachePath := set.String("cache-path", "", "path to cache")
confDBPath := set.String("db-path", "gonic.db", "path to database (optional)")
confScanInterval := set.Int("scan-interval", 0, "interval (in minutes) to automatically scan music (optional)")
confScanIntervalMins := set.Int("scan-interval", 0, "interval (in minutes) to automatically scan music (optional)")
confScanWatcher := set.Bool("scan-watcher-enabled", false, "whether to watch file system for new music and rescan (optional)")
confJukeboxEnabled := set.Bool("jukebox-enabled", false, "whether the subsonic jukebox api should be enabled (optional)")
confPodcastPurgeAgeDays := set.Int("podcast-purge-age", 0, "age (in days) to purge podcast episodes if not accessed (optional)")
confProxyPrefix := set.String("proxy-prefix", "", "url path prefix to use if behind proxy. eg '/gonic' (optional)")
confGenreSplit := set.String("genre-split", "\n", "character or string to split genre tag data on (optional)")
confHTTPLog := set.Bool("http-log", true, "http request logging (optional)")
@@ -131,8 +133,8 @@ func main() {
g.Add(server.StartHTTP(*confListenAddr, *confTLSCert, *confTLSKey))
g.Add(server.StartSessionClean(cleanTimeDuration))
g.Add(server.StartPodcastRefresher(time.Hour))
if *confScanInterval > 0 {
tickerDur := time.Duration(*confScanInterval) * time.Minute
if *confScanIntervalMins > 0 {
tickerDur := time.Duration(*confScanIntervalMins) * time.Minute
g.Add(server.StartScanTicker(tickerDur))
}
if *confScanWatcher {
@@ -141,6 +143,9 @@ func main() {
if *confJukeboxEnabled {
g.Add(server.StartJukebox())
}
if *confPodcastPurgeAgeDays > 0 {
g.Add(server.StartPodcastPurger(time.Duration(*confPodcastPurgeAgeDays) * 24 * time.Hour))
}
if err := g.Run(); err != nil {
log.Panicf("error in job: %v", err)