fix breaking single download

swagger
Akhil Gupta 4 years ago
parent ea3a8e090d
commit 3315758a17

@ -318,12 +318,18 @@ func DownloadMissingImages() error {
return err return err
} }
for _, item := range *items { for _, item := range *items {
downloadImageLocally(item) downloadImageLocally(item.ID)
} }
return nil return nil
} }
func downloadImageLocally(podcastItem db.PodcastItem) error { func downloadImageLocally(podcastItemId string) error {
var podcastItem db.PodcastItem
err := db.GetPodcastItemById(podcastItemId, &podcastItem)
if err != nil {
return err
}
path, err := DownloadImage(podcastItem.Image, podcastItem.ID, podcastItem.Podcast.Title) path, err := DownloadImage(podcastItem.Image, podcastItem.ID, podcastItem.Podcast.Title)
if err != nil { if err != nil {
return err return err
@ -350,8 +356,10 @@ func SetPodcastItemBookmarkStatus(id string, bookmark bool) error {
func SetPodcastItemAsDownloaded(id string, location string) error { func SetPodcastItemAsDownloaded(id string, location string) error {
var podcastItem db.PodcastItem var podcastItem db.PodcastItem
err := db.GetPodcastItemById(id, &podcastItem) err := db.GetPodcastItemById(id, &podcastItem)
if err != nil { if err != nil {
fmt.Println("Location", err.Error())
return err return err
} }
podcastItem.DownloadDate = time.Now() podcastItem.DownloadDate = time.Now()
@ -494,13 +502,17 @@ func DownloadSingleEpisode(podcastItemId string) error {
SetPodcastItemAsQueuedForDownload(podcastItemId) SetPodcastItemAsQueuedForDownload(podcastItemId)
url, err := Download(podcastItem.FileURL, podcastItem.Title, podcastItem.Podcast.Title, GetPodcastPrefix(&podcastItem, setting)) url, err := Download(podcastItem.FileURL, podcastItem.Title, podcastItem.Podcast.Title, GetPodcastPrefix(&podcastItem, setting))
if err != nil { if err != nil {
fmt.Println(err.Error())
return err return err
} }
err = SetPodcastItemAsDownloaded(podcastItem.ID, url)
if setting.DownloadEpisodeImages { if setting.DownloadEpisodeImages {
go downloadImageLocally(podcastItem) downloadImageLocally(podcastItem.ID)
} }
return SetPodcastItemAsDownloaded(podcastItem.ID, url) return err
} }
func RefreshEpisodes() error { func RefreshEpisodes() error {

Loading…
Cancel
Save