diff --git a/backend/external_medias/handlers.go b/backend/external_medias/handlers.go index 26ec0c7..7ead1ec 100644 --- a/backend/external_medias/handlers.go +++ b/backend/external_medias/handlers.go @@ -141,7 +141,7 @@ func GetShows(env *web.Env, user *models.User, source string, category string, f for _, id := range media.IDs { pShow, _ := pShows.Has(id) wShow, _ := wShows.IsShowInWishlist(id) - show := shows.NewWithClient(id, client, pShow, wShow, env.Config.PublicDir, env.Config.ImgURLPrefix) + show := shows.NewWithClient(&polochon.Show{ImdbID: id}, client, pShow, wShow, env.Config.PublicDir, env.Config.ImgURLPrefix) // First check in the DB before := []polochon.Detailer{env.Backend.Detailer} diff --git a/backend/shows/handlers.go b/backend/shows/handlers.go index c5cf2d7..65ba5d7 100644 --- a/backend/shows/handlers.go +++ b/backend/shows/handlers.go @@ -43,7 +43,7 @@ func GetDetailsHandler(env *web.Env, w http.ResponseWriter, r *http.Request) err log.Println("Got error getting wishlisted show ", err) } - s := NewWithClient(id, client, pShow, wShow, env.Config.PublicDir, env.Config.ImgURLPrefix) + s := NewWithClient(&polochon.Show{ImdbID: id}, client, pShow, wShow, env.Config.PublicDir, env.Config.ImgURLPrefix) // First try from the db first := []polochon.Detailer{env.Backend.Detailer} // Then try from the polochon detailers @@ -89,7 +89,7 @@ func RefreshShowHandler(env *web.Env, w http.ResponseWriter, r *http.Request) er log.Println("Got error getting wishlisted show ", err) } - s := NewWithClient(id, client, pShow, wShow, env.Config.PublicDir, env.Config.ImgURLPrefix) + s := NewWithClient(&polochon.Show{ImdbID: id}, client, pShow, wShow, env.Config.PublicDir, env.Config.ImgURLPrefix) // Refresh the polochon detailers detailers := env.Config.Show.Detailers err = s.Refresh(env, detailers) @@ -161,7 +161,7 @@ func SearchShow(env *web.Env, w http.ResponseWriter, r *http.Request) error { for _, s := range shows { pShow, _ := pShows.Has(s.ImdbID) wShow, _ := wShows.IsShowInWishlist(s.ImdbID) - show := NewWithClient(s.ImdbID, client, pShow, wShow, env.Config.PublicDir, env.Config.ImgURLPrefix) + show := NewWithClient(s, client, pShow, wShow, env.Config.PublicDir, env.Config.ImgURLPrefix) // First try from the db first := []polochon.Detailer{env.Backend.Detailer} @@ -240,7 +240,8 @@ func GetWishlistHandler(env *web.Env, w http.ResponseWriter, r *http.Request) er showList := []*Show{} for _, wishedShow := range wShows.List() { pShow, _ := pShows.Has(wishedShow.ImdbID) - show := NewWithClient(wishedShow.ImdbID, client, pShow, wishedShow, env.Config.PublicDir, env.Config.ImgURLPrefix) + poloShow := &polochon.Show{ImdbID: wishedShow.ImdbID} + show := NewWithClient(poloShow, client, pShow, wishedShow, env.Config.PublicDir, env.Config.ImgURLPrefix) // First check in the DB before := []polochon.Detailer{env.Backend.Detailer} diff --git a/backend/shows/shows.go b/backend/shows/shows.go index c008557..9733895 100644 --- a/backend/shows/shows.go +++ b/backend/shows/shows.go @@ -65,11 +65,9 @@ func New(imdbID string, publicDir, imgURLPrefix string) *Show { } // NewWithClient returns a new Show with a polochon ShowConfig -func NewWithClient(imdbID string, client *papi.Client, pShow *papi.Show, wShow *models.WishedShow, publicDir, imgURLPrefix string) *Show { +func NewWithClient(show *polochon.Show, client *papi.Client, pShow *papi.Show, wShow *models.WishedShow, publicDir, imgURLPrefix string) *Show { s := &Show{ - Show: &polochon.Show{ - ImdbID: imdbID, - }, + Show: show, client: client, pShow: pShow, publicDir: publicDir, @@ -219,7 +217,7 @@ func getPolochonShows(env *web.Env, user *models.User) ([]*Show, error) { // Create Shows objects from the shows retrieved for _, pShow := range pshows.List() { wShow, _ := wShows.IsShowInWishlist(pShow.ImdbID) - show := NewWithClient(pShow.ImdbID, client, pShow, wShow, env.Config.PublicDir, env.Config.ImgURLPrefix) + show := NewWithClient(&polochon.Show{ImdbID: pShow.ImdbID}, client, pShow, wShow, env.Config.PublicDir, env.Config.ImgURLPrefix) shows = append(shows, show) } return shows, nil