weee
This commit is contained in:
@@ -252,6 +252,30 @@ func (m *Manager) DownloadEpisode(ctx context.Context, episodeID string) error {
|
||||
return database.SetPodcastEpisodeMediaFile(m.DB, episodeID, mf.ID)
|
||||
}
|
||||
|
||||
// DownloadChannel downloads every episode in a channel that is not already
|
||||
// complete or in progress. Downloads are run in feed order and still pass
|
||||
// through the manager's concurrency limiter.
|
||||
func (m *Manager) DownloadChannel(ctx context.Context, channelID string) error {
|
||||
episodes, err := database.ListPodcastEpisodes(m.DB, channelID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, episode := range episodes {
|
||||
if episode.Status == "completed" || episode.Status == "downloading" {
|
||||
continue
|
||||
}
|
||||
if err := m.DownloadEpisode(ctx, episode.ID); err != nil {
|
||||
if m.Log != nil {
|
||||
m.Log.Warn("podcast episode download failed", "episode", episode.ID, "err", err)
|
||||
}
|
||||
}
|
||||
if err := ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Manager) downloadToFile(ctx context.Context, sourceURL, destPath string) error {
|
||||
if err := netguard.ValidateURL(sourceURL); err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user