feat: Update player API to use id_type in path

All Russian players now use format: /players/{player}/{id_type}/{id}
- id_type can be kp (Kinopoisk) or imdb
- Alloha, Lumex, Vibix, HDVB support both ID types
- Added validation for id_type parameter
- Updated handlers to parse id_type from path
This commit is contained in:
2025-10-18 20:21:13 +00:00
parent 43ca411897
commit b5d9f3c57d
12 changed files with 835 additions and 85 deletions

View File

@@ -7,14 +7,16 @@ import (
)
type TVService struct {
db *mongo.Database
tmdb *TMDBService
db *mongo.Database
tmdb *TMDBService
kpService *KinopoiskService
}
func NewTVService(db *mongo.Database, tmdb *TMDBService) *TVService {
func NewTVService(db *mongo.Database, tmdb *TMDBService, kpService *KinopoiskService) *TVService {
return &TVService{
db: db,
tmdb: tmdb,
db: db,
tmdb: tmdb,
kpService: kpService,
}
}
@@ -23,6 +25,12 @@ func (s *TVService) Search(query string, page int, language string, year int) (*
}
func (s *TVService) GetByID(id int, language string) (*models.TVShow, error) {
if ShouldUseKinopoisk(language) && s.kpService != nil {
kpFilm, err := s.kpService.GetFilmByKinopoiskId(id)
if err == nil && kpFilm != nil {
return MapKPFilmToTVShow(kpFilm), nil
}
}
return s.tmdb.GetTVShow(id, language)
}