mirror of
https://github.com/simon-ding/polaris.git
synced 2026-04-21 11:17:30 +08:00
feat: add db extra fields
This commit is contained in:
@@ -47,7 +47,16 @@ type MediaLimiter struct {
|
||||
}
|
||||
|
||||
type MediaExtras struct {
|
||||
IsAdult bool `json:"is_adult"`
|
||||
IsJav bool `json:"is_jav"`
|
||||
JavId string `json:"javid"`
|
||||
IsAdultMovie bool `json:"is_adult_movie"`
|
||||
JavId string `json:"javid"`
|
||||
//OriginCountry []string `json:"origin_country"`
|
||||
OriginalLanguage string `json:"original_language"`
|
||||
Genres []struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
} `json:"genres"`
|
||||
}
|
||||
|
||||
func (m *MediaExtras) IsJav() bool {
|
||||
return m.IsAdultMovie && m.JavId != ""
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ func SearchMovie(db1 *db.Client, param *SearchParam) ([]torznab.Result, error) {
|
||||
}
|
||||
|
||||
res := searchWithTorznab(db1, movieDetail.NameEn, movieDetail.NameCn, movieDetail.OriginalName)
|
||||
if movieDetail.Extras.IsJav {
|
||||
if movieDetail.Extras.IsJav(){
|
||||
res1 := searchWithTorznab(db1, movieDetail.Extras.JavId)
|
||||
res = append(res, res1...)
|
||||
}
|
||||
@@ -180,7 +180,7 @@ func SearchMovie(db1 *db.Client, param *SearchParam) ([]torznab.Result, error) {
|
||||
if !torrentNameOk(movieDetail, r.Name) {
|
||||
continue
|
||||
}
|
||||
if !movieDetail.Extras.IsJav {
|
||||
if !movieDetail.Extras.IsJav() {
|
||||
ss := strings.Split(movieDetail.AirDate, "-")[0]
|
||||
year, _ := strconv.Atoi(ss)
|
||||
if meta.Year != year && meta.Year != year-1 && meta.Year != year+1 { //year not match
|
||||
@@ -301,7 +301,7 @@ func dedup(list []torznab.Result) []torznab.Result {
|
||||
}
|
||||
|
||||
func torrentNameOk(detail *db.MediaDetails, torrentName string) bool {
|
||||
if detail.Extras.IsJav && isNameAcceptable(torrentName, detail.Extras.JavId) {
|
||||
if detail.Extras.IsJav() && isNameAcceptable(torrentName, detail.Extras.JavId) {
|
||||
return true
|
||||
}
|
||||
return isNameAcceptable(torrentName, detail.NameCn) || isNameAcceptable(torrentName, detail.NameEn) ||
|
||||
|
||||
@@ -152,6 +152,10 @@ func (s *Server) AddTv2Watchlist(c *gin.Context) (interface{}, error) {
|
||||
TargetDir: in.Folder,
|
||||
DownloadHistoryEpisodes: in.DownloadHistoryEpisodes,
|
||||
Limiter: schema.MediaLimiter{SizeMin: in.SizeMin, SizeMax: in.SizeMax},
|
||||
Extras: schema.MediaExtras{
|
||||
OriginalLanguage: detail.OriginalLanguage,
|
||||
Genres: detail.Genres,
|
||||
},
|
||||
}
|
||||
|
||||
r, err := s.db.AddMediaWatchlist(m, epIds)
|
||||
@@ -176,7 +180,7 @@ func (s *Server) AddTv2Watchlist(c *gin.Context) (interface{}, error) {
|
||||
}
|
||||
|
||||
func isJav(detail *tmdb.MovieDetails) bool {
|
||||
if detail.Adult && len(detail.ProductionCountries)> 0 && strings.ToUpper(detail.ProductionCountries[0].Iso3166_1) == "JP" {
|
||||
if detail.Adult && len(detail.ProductionCountries) > 0 && strings.ToUpper(detail.ProductionCountries[0].Iso3166_1) == "JP" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@@ -217,7 +221,6 @@ func (s *Server) AddMovie2Watchlist(c *gin.Context) (interface{}, error) {
|
||||
}
|
||||
log.Infof("find detail for movie id %d: %v", in.TmdbID, detail)
|
||||
|
||||
|
||||
epid, err := s.db.SaveEposideDetail(&ent.Episode{
|
||||
SeasonNumber: 1,
|
||||
EpisodeNumber: 1,
|
||||
@@ -245,17 +248,18 @@ func (s *Server) AddMovie2Watchlist(c *gin.Context) (interface{}, error) {
|
||||
TargetDir: in.Folder,
|
||||
Limiter: schema.MediaLimiter{SizeMin: in.SizeMin, SizeMax: in.SizeMax},
|
||||
}
|
||||
|
||||
extras := schema.MediaExtras{
|
||||
IsAdultMovie: detail.Adult,
|
||||
OriginalLanguage: detail.OriginalLanguage,
|
||||
Genres: detail.Genres,
|
||||
}
|
||||
if isJav(detail) {
|
||||
javid := s.getJavid(in.TmdbID)
|
||||
movie.Extras = schema.MediaExtras{
|
||||
IsJav: true,
|
||||
JavId: javid,
|
||||
}
|
||||
extras.JavId = javid
|
||||
}
|
||||
if detail.Adult {
|
||||
movie.Extras.IsAdult = true
|
||||
}
|
||||
|
||||
|
||||
movie.Extras = extras
|
||||
r, err := s.db.AddMediaWatchlist(&movie, []int{epid})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "add to list")
|
||||
|
||||
Reference in New Issue
Block a user