Backend: Change the way we store polochon config
This commit is contained in:
parent
74a526e6c7
commit
0ac63cdde6
@ -4,7 +4,6 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
polochon "github.com/odwrtw/polochon/lib"
|
|
||||||
polochonConfig "github.com/odwrtw/polochon/lib/configuration"
|
polochonConfig "github.com/odwrtw/polochon/lib/configuration"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
@ -20,15 +19,7 @@ type Config struct {
|
|||||||
ImgURLPrefix string `yaml:"img_url_prefix"`
|
ImgURLPrefix string `yaml:"img_url_prefix"`
|
||||||
PeriodicRefresh PeriodicRefreshConfig `yaml:"periodic_refresh"`
|
PeriodicRefresh PeriodicRefreshConfig `yaml:"periodic_refresh"`
|
||||||
|
|
||||||
MovieExplorers []polochon.Explorer
|
PolochonConfig *polochonConfig.Config
|
||||||
MovieDetailers []polochon.Detailer
|
|
||||||
MovieTorrenters []polochon.Torrenter
|
|
||||||
MovieSearchers []polochon.Searcher
|
|
||||||
|
|
||||||
ShowExplorers []polochon.Explorer
|
|
||||||
ShowDetailers []polochon.Detailer
|
|
||||||
ShowTorrenters []polochon.Torrenter
|
|
||||||
ShowSearchers []polochon.Searcher
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuthorizerConfig is the config for the authentication
|
// AuthorizerConfig is the config for the authentication
|
||||||
@ -54,7 +45,8 @@ func Load(path string, log *logrus.Entry) (*Config, error) {
|
|||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
cf := &Config{}
|
cf := &Config{}
|
||||||
polochonCf := &polochonConfig.ConfigFileRoot{}
|
polochonConfigFile := &polochonConfig.ConfigFileRoot{}
|
||||||
|
polochonConfig := &polochonConfig.Config{}
|
||||||
|
|
||||||
// Read it
|
// Read it
|
||||||
b, err := ioutil.ReadAll(file)
|
b, err := ioutil.ReadAll(file)
|
||||||
@ -69,30 +61,24 @@ func Load(path string, log *logrus.Entry) (*Config, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unmarshal its content into the polochon.ConfigFileRoot obj
|
// Unmarshal its content into the polochon.ConfigFileRoot obj
|
||||||
err = yaml.Unmarshal(b, polochonCf)
|
err = yaml.Unmarshal(b, polochonConfigFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init all the show torrenters / detailers / searchers / explorers
|
// Init all the show torrenters / detailers / searchers / explorers
|
||||||
showConf, err := polochonCf.InitShow(log)
|
err = polochonConfig.InitShow(polochonConfigFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
cf.ShowTorrenters = showConf.Torrenters
|
|
||||||
cf.ShowDetailers = showConf.Detailers
|
|
||||||
cf.ShowSearchers = showConf.Searchers
|
|
||||||
cf.ShowExplorers = showConf.Explorers
|
|
||||||
|
|
||||||
// Init all the movie torrenters / detailers / searchers / explorers
|
// Init all the movie torrenters / detailers / searchers / explorers
|
||||||
movieConf, err := polochonCf.InitMovie(log)
|
err = polochonConfig.InitMovie(polochonConfigFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
cf.MovieTorrenters = movieConf.Torrenters
|
|
||||||
cf.MovieDetailers = movieConf.Detailers
|
cf.PolochonConfig = polochonConfig
|
||||||
cf.MovieSearchers = movieConf.Searchers
|
|
||||||
cf.MovieExplorers = movieConf.Explorers
|
|
||||||
|
|
||||||
return cf, nil
|
return cf, nil
|
||||||
}
|
}
|
||||||
|
@ -3,21 +3,21 @@ package extmedias
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
polochon "github.com/odwrtw/polochon/lib"
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/backend"
|
"git.quimbo.fr/odwrtw/canape/backend/backend"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/movies"
|
"git.quimbo.fr/odwrtw/canape/backend/movies"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/shows"
|
"git.quimbo.fr/odwrtw/canape/backend/shows"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/web"
|
"git.quimbo.fr/odwrtw/canape/backend/web"
|
||||||
|
polochon "github.com/odwrtw/polochon/lib"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewExplorer returns a polochon.Explorer from the list of Explorers in the config
|
// NewExplorer returns a polochon.Explorer from the list of Explorers in the config
|
||||||
func NewExplorer(env *web.Env, mediaType, name string) (polochon.Explorer, error) {
|
func NewExplorer(env *web.Env, mediaType, name string) (polochon.Explorer, error) {
|
||||||
var explorers []polochon.Explorer
|
var explorers []polochon.Explorer
|
||||||
if mediaType == "movie" {
|
if mediaType == "movie" {
|
||||||
explorers = env.Config.MovieExplorers
|
explorers = env.Config.PolochonConfig.Movie.Explorers
|
||||||
} else {
|
} else {
|
||||||
explorers = env.Config.ShowExplorers
|
explorers = env.Config.PolochonConfig.Show.Explorers
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, e := range explorers {
|
for _, e := range explorers {
|
||||||
@ -96,7 +96,7 @@ func GetMediaIDs(env *web.Env, mediaType string, source string, category string)
|
|||||||
func RefreshShows(env *web.Env) {
|
func RefreshShows(env *web.Env) {
|
||||||
showMap := make(map[string]*shows.Show)
|
showMap := make(map[string]*shows.Show)
|
||||||
// Iterate over all show explorers
|
// Iterate over all show explorers
|
||||||
for _, showExplorer := range env.Config.ShowExplorers {
|
for _, showExplorer := range env.Config.PolochonConfig.Show.Explorers {
|
||||||
availableOptions := showExplorer.AvailableShowOptions()
|
availableOptions := showExplorer.AvailableShowOptions()
|
||||||
// Iterate over all show explorer options
|
// Iterate over all show explorer options
|
||||||
for _, option := range availableOptions {
|
for _, option := range availableOptions {
|
||||||
@ -132,7 +132,7 @@ func RefreshShows(env *web.Env) {
|
|||||||
for id := range showMap {
|
for id := range showMap {
|
||||||
show := shows.New(id, env.Config.PublicDir, env.Config.ImgURLPrefix)
|
show := shows.New(id, env.Config.PublicDir, env.Config.ImgURLPrefix)
|
||||||
// Refresh the shows
|
// Refresh the shows
|
||||||
err := show.Refresh(env, env.Config.ShowDetailers)
|
err := show.Refresh(env, env.Config.PolochonConfig.Show.Detailers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.Log.Warnf("error while refreshing show %s : %s", id, err)
|
env.Log.Warnf("error while refreshing show %s : %s", id, err)
|
||||||
}
|
}
|
||||||
@ -146,7 +146,7 @@ func RefreshShows(env *web.Env) {
|
|||||||
// too many requests on our torrenters
|
// too many requests on our torrenters
|
||||||
for _, e := range show.LastSeasonEpisodes() {
|
for _, e := range show.LastSeasonEpisodes() {
|
||||||
// Refresh the torrents
|
// Refresh the torrents
|
||||||
err := shows.RefreshTorrents(env, e, env.Config.ShowTorrenters)
|
err := shows.RefreshTorrents(env, e, env.Config.PolochonConfig.Show.Torrenters)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.Log.Error(err)
|
env.Log.Error(err)
|
||||||
}
|
}
|
||||||
@ -162,7 +162,7 @@ func RefreshShows(env *web.Env) {
|
|||||||
func RefreshMovies(env *web.Env) {
|
func RefreshMovies(env *web.Env) {
|
||||||
movieMap := make(map[string]struct{})
|
movieMap := make(map[string]struct{})
|
||||||
// Iterate over all movie explorers
|
// Iterate over all movie explorers
|
||||||
for _, movieExplorer := range env.Config.MovieExplorers {
|
for _, movieExplorer := range env.Config.PolochonConfig.Movie.Explorers {
|
||||||
availableOptions := movieExplorer.AvailableMovieOptions()
|
availableOptions := movieExplorer.AvailableMovieOptions()
|
||||||
// Iterate over all movie explorer options
|
// Iterate over all movie explorer options
|
||||||
for _, option := range availableOptions {
|
for _, option := range availableOptions {
|
||||||
@ -198,12 +198,12 @@ func RefreshMovies(env *web.Env) {
|
|||||||
for id := range movieMap {
|
for id := range movieMap {
|
||||||
movie := movies.New(id, nil, nil, false, env.Config.PublicDir, env.Config.ImgURLPrefix)
|
movie := movies.New(id, nil, nil, false, env.Config.PublicDir, env.Config.ImgURLPrefix)
|
||||||
// Refresh the movie
|
// Refresh the movie
|
||||||
err := movie.Refresh(env, env.Config.MovieDetailers)
|
err := movie.Refresh(env, env.Config.PolochonConfig.Movie.Detailers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.Log.Warnf("error while refreshing movie %s : %s", id, err)
|
env.Log.Warnf("error while refreshing movie %s : %s", id, err)
|
||||||
}
|
}
|
||||||
// Refresh its torrents
|
// Refresh its torrents
|
||||||
err = movie.RefreshTorrents(env, env.Config.MovieTorrenters)
|
err = movie.RefreshTorrents(env, env.Config.PolochonConfig.Movie.Torrenters)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.Log.Warnf("error while refreshing movie torrents %s : %s", id, err)
|
env.Log.Warnf("error while refreshing movie torrents %s : %s", id, err)
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,14 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
polochon "github.com/odwrtw/polochon/lib"
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/auth"
|
"git.quimbo.fr/odwrtw/canape/backend/auth"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/backend"
|
"git.quimbo.fr/odwrtw/canape/backend/backend"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/movies"
|
"git.quimbo.fr/odwrtw/canape/backend/movies"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/shows"
|
"git.quimbo.fr/odwrtw/canape/backend/shows"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/users"
|
"git.quimbo.fr/odwrtw/canape/backend/users"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/web"
|
"git.quimbo.fr/odwrtw/canape/backend/web"
|
||||||
|
polochon "github.com/odwrtw/polochon/lib"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RefreshHandler refresh the explored movies
|
// RefreshHandler refresh the explored movies
|
||||||
@ -86,7 +86,7 @@ func GetMovies(env *web.Env, user *users.User, source string, category string) (
|
|||||||
// First check in the DB
|
// First check in the DB
|
||||||
before := []polochon.Detailer{env.Backend.Detailer}
|
before := []polochon.Detailer{env.Backend.Detailer}
|
||||||
// Then with the default detailers
|
// Then with the default detailers
|
||||||
after := env.Config.MovieDetailers
|
after := env.Config.PolochonConfig.Movie.Detailers
|
||||||
err := movie.GetAndFetch(env, before, after)
|
err := movie.GetAndFetch(env, before, after)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.Log.Errorf("error while getting movie details : %s", err)
|
env.Log.Errorf("error while getting movie details : %s", err)
|
||||||
@ -148,7 +148,7 @@ func GetShows(env *web.Env, user *users.User, source string, category string, fo
|
|||||||
// First check in the DB
|
// First check in the DB
|
||||||
before := []polochon.Detailer{env.Backend.Detailer}
|
before := []polochon.Detailer{env.Backend.Detailer}
|
||||||
// Then with the default detailers
|
// Then with the default detailers
|
||||||
after := env.Config.ShowDetailers
|
after := env.Config.PolochonConfig.Show.Detailers
|
||||||
err := show.GetAndFetch(env, before, after)
|
err := show.GetAndFetch(env, before, after)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.Log.Errorf("error while getting show details : %s", err)
|
env.Log.Errorf("error while getting show details : %s", err)
|
||||||
|
@ -6,16 +6,16 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
|
||||||
"github.com/odwrtw/papi"
|
|
||||||
polochon "github.com/odwrtw/polochon/lib"
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/auth"
|
"git.quimbo.fr/odwrtw/canape/backend/auth"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/backend"
|
"git.quimbo.fr/odwrtw/canape/backend/backend"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/config"
|
"git.quimbo.fr/odwrtw/canape/backend/config"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/subtitles"
|
"git.quimbo.fr/odwrtw/canape/backend/subtitles"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/users"
|
"git.quimbo.fr/odwrtw/canape/backend/users"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/web"
|
"git.quimbo.fr/odwrtw/canape/backend/web"
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
"github.com/odwrtw/papi"
|
||||||
|
polochon "github.com/odwrtw/polochon/lib"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PolochonMoviesHandler will returns movies from Polochon
|
// PolochonMoviesHandler will returns movies from Polochon
|
||||||
@ -45,7 +45,7 @@ func PolochonMoviesHandler(env *web.Env, w http.ResponseWriter, r *http.Request)
|
|||||||
// 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 detailer
|
// Then try from the polochon detailer
|
||||||
detailers := env.Config.MovieDetailers
|
detailers := env.Config.PolochonConfig.Movie.Detailers
|
||||||
err := m.GetAndFetch(env, first, detailers)
|
err := m.GetAndFetch(env, first, detailers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.Log.Error(err)
|
env.Log.Error(err)
|
||||||
@ -97,12 +97,12 @@ func RefreshMovieHandler(env *web.Env, w http.ResponseWriter, r *http.Request) e
|
|||||||
m := New(id, client, pMovie, isWishlisted, env.Config.PublicDir, env.Config.ImgURLPrefix)
|
m := New(id, client, pMovie, isWishlisted, env.Config.PublicDir, env.Config.ImgURLPrefix)
|
||||||
|
|
||||||
// Refresh the movie's infos
|
// Refresh the movie's infos
|
||||||
if err := m.Refresh(env, env.Config.MovieDetailers); err != nil {
|
if err := m.Refresh(env, env.Config.PolochonConfig.Movie.Detailers); err != nil {
|
||||||
env.Log.Error(err)
|
env.Log.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh the movie's torrents
|
// Refresh the movie's torrents
|
||||||
if err := m.RefreshTorrents(env, env.Config.MovieTorrenters); err != nil {
|
if err := m.RefreshTorrents(env, env.Config.PolochonConfig.Movie.Torrenters); err != nil {
|
||||||
env.Log.Error(err)
|
env.Log.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ func SearchMovie(env *web.Env, w http.ResponseWriter, r *http.Request) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var movies []*polochon.Movie
|
var movies []*polochon.Movie
|
||||||
searchers := env.Config.MovieSearchers
|
searchers := env.Config.PolochonConfig.Movie.Searchers
|
||||||
// Search for the movie with all the Searchers
|
// Search for the movie with all the Searchers
|
||||||
for _, searcher := range searchers {
|
for _, searcher := range searchers {
|
||||||
result, err := searcher.SearchMovie(search, env.Log)
|
result, err := searcher.SearchMovie(search, env.Log)
|
||||||
@ -167,7 +167,7 @@ func SearchMovie(env *web.Env, w http.ResponseWriter, r *http.Request) error {
|
|||||||
// First check in the DB
|
// First check in the DB
|
||||||
before := []polochon.Detailer{env.Backend.Detailer}
|
before := []polochon.Detailer{env.Backend.Detailer}
|
||||||
// Then with the default detailers
|
// Then with the default detailers
|
||||||
after := env.Config.MovieDetailers
|
after := env.Config.PolochonConfig.Movie.Detailers
|
||||||
err := movie.GetAndFetch(env, before, after)
|
err := movie.GetAndFetch(env, before, after)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.Log.Errorf("error while getting movie details : %s", err)
|
env.Log.Errorf("error while getting movie details : %s", err)
|
||||||
@ -293,7 +293,7 @@ func GetWishlistHandler(env *web.Env, w http.ResponseWriter, r *http.Request) er
|
|||||||
// First check in the DB
|
// First check in the DB
|
||||||
before := []polochon.Detailer{env.Backend.Detailer}
|
before := []polochon.Detailer{env.Backend.Detailer}
|
||||||
// Then with the default detailers
|
// Then with the default detailers
|
||||||
after := env.Config.MovieDetailers
|
after := env.Config.PolochonConfig.Movie.Detailers
|
||||||
err := movie.GetAndFetch(env, before, after)
|
err := movie.GetAndFetch(env, before, after)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.Log.Errorf("error while getting movie details : %s", err)
|
env.Log.Errorf("error while getting movie details : %s", err)
|
||||||
|
@ -9,14 +9,14 @@ import (
|
|||||||
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
|
||||||
"github.com/odwrtw/papi"
|
|
||||||
polochon "github.com/odwrtw/polochon/lib"
|
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/auth"
|
"git.quimbo.fr/odwrtw/canape/backend/auth"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/backend"
|
"git.quimbo.fr/odwrtw/canape/backend/backend"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/subtitles"
|
"git.quimbo.fr/odwrtw/canape/backend/subtitles"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/users"
|
"git.quimbo.fr/odwrtw/canape/backend/users"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/web"
|
"git.quimbo.fr/odwrtw/canape/backend/web"
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
"github.com/odwrtw/papi"
|
||||||
|
polochon "github.com/odwrtw/polochon/lib"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrPolochonUnavailable is an error returned if the polochon server is not available
|
// ErrPolochonUnavailable is an error returned if the polochon server is not available
|
||||||
@ -52,7 +52,7 @@ func GetDetailsHandler(env *web.Env, w http.ResponseWriter, r *http.Request) err
|
|||||||
// 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
|
||||||
detailers := env.Config.ShowDetailers
|
detailers := env.Config.PolochonConfig.Show.Detailers
|
||||||
err = s.GetAndFetch(env, first, detailers)
|
err = s.GetAndFetch(env, first, detailers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.Log.Error(err)
|
env.Log.Error(err)
|
||||||
@ -100,7 +100,7 @@ func RefreshShowHandler(env *web.Env, w http.ResponseWriter, r *http.Request) er
|
|||||||
|
|
||||||
s := NewWithClient(id, client, pShow, wShow, env.Config.PublicDir, env.Config.ImgURLPrefix)
|
s := NewWithClient(id, client, pShow, wShow, env.Config.PublicDir, env.Config.ImgURLPrefix)
|
||||||
// Refresh the polochon detailers
|
// Refresh the polochon detailers
|
||||||
detailers := env.Config.ShowDetailers
|
detailers := env.Config.PolochonConfig.Show.Detailers
|
||||||
err = s.Refresh(env, detailers)
|
err = s.Refresh(env, detailers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.Log.Error(err)
|
env.Log.Error(err)
|
||||||
@ -110,7 +110,7 @@ func RefreshShowHandler(env *web.Env, w http.ResponseWriter, r *http.Request) er
|
|||||||
env.Log.Debug("getting episodes torrents")
|
env.Log.Debug("getting episodes torrents")
|
||||||
for _, e := range s.Episodes {
|
for _, e := range s.Episodes {
|
||||||
// Get torrents from the db
|
// Get torrents from the db
|
||||||
err := RefreshTorrents(env, e, env.Config.ShowTorrenters)
|
err := RefreshTorrents(env, e, env.Config.PolochonConfig.Show.Torrenters)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.Log.Error(err)
|
env.Log.Error(err)
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ func SearchShow(env *web.Env, w http.ResponseWriter, r *http.Request) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var shows []*polochon.Show
|
var shows []*polochon.Show
|
||||||
searchers := env.Config.ShowSearchers
|
searchers := env.Config.PolochonConfig.Show.Searchers
|
||||||
// Iterate on all the searchers to search for the show
|
// Iterate on all the searchers to search for the show
|
||||||
for _, searcher := range searchers {
|
for _, searcher := range searchers {
|
||||||
result, err := searcher.SearchShow(search, env.Log)
|
result, err := searcher.SearchShow(search, env.Log)
|
||||||
@ -174,7 +174,7 @@ func SearchShow(env *web.Env, w http.ResponseWriter, r *http.Request) error {
|
|||||||
// 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
|
||||||
detailers := env.Config.ShowDetailers
|
detailers := env.Config.PolochonConfig.Show.Detailers
|
||||||
err := show.GetAndFetch(env, first, detailers)
|
err := show.GetAndFetch(env, first, detailers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.Log.Error(err)
|
env.Log.Error(err)
|
||||||
@ -265,7 +265,7 @@ func GetWishlistHandler(env *web.Env, w http.ResponseWriter, r *http.Request) er
|
|||||||
// First check in the DB
|
// First check in the DB
|
||||||
before := []polochon.Detailer{env.Backend.Detailer}
|
before := []polochon.Detailer{env.Backend.Detailer}
|
||||||
// Then with the default detailers
|
// Then with the default detailers
|
||||||
after := env.Config.ShowDetailers
|
after := env.Config.PolochonConfig.Show.Detailers
|
||||||
err := show.GetAndFetch(env, before, after)
|
err := show.GetAndFetch(env, before, after)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.Log.Errorf("error while getting show details : %s", err)
|
env.Log.Errorf("error while getting show details : %s", err)
|
||||||
@ -297,7 +297,7 @@ func PolochonShowsHandler(env *web.Env, w http.ResponseWriter, r *http.Request)
|
|||||||
// 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 detailer
|
// Then try from the polochon detailer
|
||||||
detailers := env.Config.ShowDetailers
|
detailers := env.Config.PolochonConfig.Show.Detailers
|
||||||
err := s.GetAndFetch(env, first, detailers)
|
err := s.GetAndFetch(env, first, detailers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.Log.Error(err)
|
env.Log.Error(err)
|
||||||
@ -330,19 +330,19 @@ func RefreshEpisodeHandler(env *web.Env, w http.ResponseWriter, r *http.Request)
|
|||||||
|
|
||||||
pShow, err := client.GetShow(id)
|
pShow, err := client.GetShow(id)
|
||||||
if err != nil && err != papi.ErrResourceNotFound {
|
if err != nil && err != papi.ErrResourceNotFound {
|
||||||
env.Log.Warnf("Error getting show ", err)
|
env.Log.Warnf("Error getting show %q", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
e := NewEpisode(client, pShow, id, season, episode)
|
e := NewEpisode(client, pShow, id, season, episode)
|
||||||
// Refresh the episode
|
// Refresh the episode
|
||||||
err = e.Refresh(env, env.Config.ShowDetailers)
|
err = e.Refresh(env, env.Config.PolochonConfig.Show.Detailers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.Log.Error(err)
|
env.Log.Error(err)
|
||||||
return env.RenderError(w, err)
|
return env.RenderError(w, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh the torrents
|
// Refresh the torrents
|
||||||
err = e.RefreshTorrents(env, env.Config.ShowTorrenters)
|
err = e.RefreshTorrents(env, env.Config.PolochonConfig.Show.Torrenters)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.Log.Error(err)
|
env.Log.Error(err)
|
||||||
}
|
}
|
||||||
|
@ -107,9 +107,9 @@ func SearchHandler(env *web.Env, w http.ResponseWriter, r *http.Request) error {
|
|||||||
var torrenters []polochon.Torrenter
|
var torrenters []polochon.Torrenter
|
||||||
switch searchType {
|
switch searchType {
|
||||||
case "movies":
|
case "movies":
|
||||||
torrenters = env.Config.MovieTorrenters
|
torrenters = env.Config.PolochonConfig.Movie.Torrenters
|
||||||
case "shows":
|
case "shows":
|
||||||
torrenters = env.Config.ShowTorrenters
|
torrenters = env.Config.PolochonConfig.Show.Torrenters
|
||||||
default:
|
default:
|
||||||
return env.RenderError(w, errors.New("invalid search type"))
|
return env.RenderError(w, errors.New("invalid search type"))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user