Do not download images when already present

This commit is contained in:
Lucas BEE 2020-11-22 19:51:43 +01:00
parent 778d0007b5
commit 2b2135fd43

View File

@ -186,6 +186,10 @@ func (s *Show) downloadImages(env *web.Env) {
if img.url == "" {
continue
}
// Don't download image if we already have it
if _, err := os.Stat(s.imgFile(img.urlType)); err == nil {
continue
}
if err := web.Download(img.url, s.imgFile(img.urlType), img.scale); err != nil {
env.Log.Errorf("failed to dowload %s: %s", img.urlType, err)
}
@ -197,7 +201,13 @@ func (s *Show) downloadImages(env *web.Env) {
continue
}
err := web.Download(e.Thumb, s.imgFile(fmt.Sprintf("%d-%d", e.Season, e.Episode)), false)
fileName := s.imgFile(fmt.Sprintf("%d-%d", e.Season, e.Episode))
// Don't download image if we already have it
if _, err := os.Stat(fileName); err == nil {
continue
}
err := web.Download(e.Thumb, fileName, false)
if err != nil {
env.Log.Errorf("failed to dowload the thumb for season %d episode %d ( %s ) : %s", e.Season, e.Episode, e.Thumb, err)
}