Edit show.NewWithClient

The func now takes a full polochon.Show instead of just an ImdbID, so
that it we have more than an ImdbID (a TvdbID for example), we can
transmit it to the show.Show
This commit is contained in:
Lucas BEE 2020-04-03 13:48:12 +02:00
parent e5be15c954
commit 8a07623668
3 changed files with 9 additions and 10 deletions

View File

@ -141,7 +141,7 @@ func GetShows(env *web.Env, user *models.User, source string, category string, f
for _, id := range media.IDs { for _, id := range media.IDs {
pShow, _ := pShows.Has(id) pShow, _ := pShows.Has(id)
wShow, _ := wShows.IsShowInWishlist(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 // First check in the DB
before := []polochon.Detailer{env.Backend.Detailer} before := []polochon.Detailer{env.Backend.Detailer}

View File

@ -43,7 +43,7 @@ func GetDetailsHandler(env *web.Env, w http.ResponseWriter, r *http.Request) err
log.Println("Got error getting wishlisted show ", 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 try from the db
first := []polochon.Detailer{env.Backend.Detailer} first := []polochon.Detailer{env.Backend.Detailer}
// Then try from the polochon detailers // 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) 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 // Refresh the polochon detailers
detailers := env.Config.Show.Detailers detailers := env.Config.Show.Detailers
err = s.Refresh(env, 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 { for _, s := range shows {
pShow, _ := pShows.Has(s.ImdbID) pShow, _ := pShows.Has(s.ImdbID)
wShow, _ := wShows.IsShowInWishlist(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 try from the db
first := []polochon.Detailer{env.Backend.Detailer} first := []polochon.Detailer{env.Backend.Detailer}
@ -240,7 +240,8 @@ func GetWishlistHandler(env *web.Env, w http.ResponseWriter, r *http.Request) er
showList := []*Show{} showList := []*Show{}
for _, wishedShow := range wShows.List() { for _, wishedShow := range wShows.List() {
pShow, _ := pShows.Has(wishedShow.ImdbID) 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 // First check in the DB
before := []polochon.Detailer{env.Backend.Detailer} before := []polochon.Detailer{env.Backend.Detailer}

View File

@ -65,11 +65,9 @@ func New(imdbID string, publicDir, imgURLPrefix string) *Show {
} }
// NewWithClient returns a new Show with a polochon ShowConfig // 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{ s := &Show{
Show: &polochon.Show{ Show: show,
ImdbID: imdbID,
},
client: client, client: client,
pShow: pShow, pShow: pShow,
publicDir: publicDir, publicDir: publicDir,
@ -219,7 +217,7 @@ func getPolochonShows(env *web.Env, user *models.User) ([]*Show, error) {
// Create Shows objects from the shows retrieved // Create Shows objects from the shows retrieved
for _, pShow := range pshows.List() { for _, pShow := range pshows.List() {
wShow, _ := wShows.IsShowInWishlist(pShow.ImdbID) 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) shows = append(shows, show)
} }
return shows, nil return shows, nil