diff --git a/backend/external_medias/external_medias.go b/backend/external_medias/external_medias.go index 30df403..92950d0 100644 --- a/backend/external_medias/external_medias.go +++ b/backend/external_medias/external_medias.go @@ -196,7 +196,7 @@ func RefreshMovies(env *web.Env) { // Iterate over the map of movies to refresh them for id := range movieMap { - movie := movies.New(id, nil, nil, false, env.Config.PublicDir, env.Config.ImgURLPrefix) + movie := movies.New(env, id, nil, nil, false) // Refresh the movie err := movie.Refresh(env, env.Config.Movie.Detailers) if err != nil { diff --git a/backend/external_medias/handlers.go b/backend/external_medias/handlers.go index 7ead1ec..c4fc57f 100644 --- a/backend/external_medias/handlers.go +++ b/backend/external_medias/handlers.go @@ -80,7 +80,7 @@ func GetMovies(env *web.Env, user *models.User, source string, category string) // Fill all the movies infos from the list of IDs for _, id := range media.IDs { pMovie, _ := pMovies.Has(id) - movie := movies.New(id, client, pMovie, moviesWishlist.IsMovieInWishlist(id), env.Config.PublicDir, env.Config.ImgURLPrefix) + movie := movies.New(env, id, client, pMovie, moviesWishlist.IsMovieInWishlist(id)) // First check in the DB before := []polochon.Detailer{env.Backend.Detailer} // Then with the default detailers diff --git a/backend/movies/handlers.go b/backend/movies/handlers.go index 192bda6..3b02a77 100644 --- a/backend/movies/handlers.go +++ b/backend/movies/handlers.go @@ -76,7 +76,7 @@ func RefreshMovieHandler(env *web.Env, w http.ResponseWriter, r *http.Request) e } // Create a new movie - m := New(id, client, pMovie, isWishlisted, env.Config.PublicDir, env.Config.ImgURLPrefix) + m := New(env, id, client, pMovie, isWishlisted) // Refresh the movie's infos if err := m.Refresh(env, env.Config.Movie.Detailers); err != nil { @@ -141,12 +141,11 @@ func SearchMovie(env *web.Env, w http.ResponseWriter, r *http.Request) error { for _, m := range movies { pMovie, _ := pMovies.Has(m.ImdbID) movie := New( + env, m.ImdbID, client, pMovie, moviesWishlist.IsMovieInWishlist(m.ImdbID), - env.Config.PublicDir, - env.Config.ImgURLPrefix, ) // First check in the DB @@ -252,12 +251,11 @@ func GetWishlistHandler(env *web.Env, w http.ResponseWriter, r *http.Request) er for _, imdbID := range moviesWishlist.List() { pMovie, _ := pMovies.Has(imdbID) movie := New( + env, imdbID, client, pMovie, moviesWishlist.IsMovieInWishlist(imdbID), - env.Config.PublicDir, - env.Config.ImgURLPrefix, ) // First check in the DB before := []polochon.Detailer{env.Backend.Detailer} diff --git a/backend/movies/movies.go b/backend/movies/movies.go index 9ab6d68..5a7f2a4 100644 --- a/backend/movies/movies.go +++ b/backend/movies/movies.go @@ -74,12 +74,12 @@ func (m *Movie) MarshalJSON() ([]byte, error) { } // New returns a new Movie with all the needed infos -func New(imdbID string, client *papi.Client, pMovie *papi.Movie, isWishlisted bool, publicDir, imgURLPrefix string) *Movie { +func New(env *web.Env, imdbID string, client *papi.Client, pMovie *papi.Movie, isWishlisted bool) *Movie { return &Movie{ client: client, pMovie: pMovie, - publicDir: publicDir, - imgURLPrefix: imgURLPrefix, + publicDir: env.Config.PublicDir, + imgURLPrefix: env.Config.ImgURLPrefix, Wishlisted: isWishlisted, Movie: &polochon.Movie{ ImdbID: imdbID, @@ -115,7 +115,7 @@ func (m *Movie) GetDetails(env *web.Env, detailers []polochon.Detailer) error { // If found, return // If not, retrives details with the detailers 'after' and update them in // database -func (m *Movie) GetAndFetch(env *web.Env, before []polochon.Detailer, after []polochon.Detailer) error { +func (m *Movie) GetAndFetch(env *web.Env, before, after []polochon.Detailer) error { log := env.Log.WithFields(logrus.Fields{ "imdb_id": m.ImdbID, "function": "movies.GetAndFetch", @@ -182,7 +182,7 @@ func (m *Movie) GetTorrents(env *web.Env, torrenters []polochon.Torrenter) error // If found, return // If not, retrives torrents with the torrenters 'after' and update them in // database -func (m *Movie) GetAndFetchTorrents(env *web.Env, before []polochon.Torrenter, after []polochon.Torrenter) error { +func (m *Movie) GetAndFetchTorrents(env *web.Env, before, after []polochon.Torrenter) error { log := env.Log.WithFields(logrus.Fields{ "imdb_id": m.ImdbID, "function": "movies.GetAndFetchTorrents", @@ -278,12 +278,11 @@ func getPolochonMovies(user *models.User, env *web.Env) ([]*Movie, error) { // Create Movies objects from the movies retrieved for _, pmovie := range pmovies.List() { movie := New( + env, pmovie.ImdbID, client, pmovie, moviesWishlist.IsMovieInWishlist(pmovie.ImdbID), - env.Config.PublicDir, - env.Config.ImgURLPrefix, ) movies = append(movies, movie) }