fix: 🐛 fix a bug
This commit is contained in:
parent
dd3853af7b
commit
e332660f24
@ -14,6 +14,8 @@ func (hq *Handlers) GetTVShow(c *gin.Context) {
|
|||||||
|
|
||||||
seasons := scraper.ScrapeSeasons(ttShowID)
|
seasons := scraper.ScrapeSeasons(ttShowID)
|
||||||
|
|
||||||
|
slog.Info("scraped seasons", "ttid", ttShowID)
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"seasons": seasons,
|
"seasons": seasons,
|
||||||
})
|
})
|
||||||
|
|||||||
@ -34,7 +34,6 @@ func ScrapeSeasons(ttImdb string) []Season {
|
|||||||
colly.AllowedDomains("imdb.com", "www.imdb.com"),
|
colly.AllowedDomains("imdb.com", "www.imdb.com"),
|
||||||
)
|
)
|
||||||
|
|
||||||
//var allEpisodes []Episode
|
|
||||||
var allSeasons []Season
|
var allSeasons []Season
|
||||||
var seasons []int
|
var seasons []int
|
||||||
|
|
||||||
@ -49,6 +48,7 @@ func ScrapeSeasons(ttImdb string) []Season {
|
|||||||
c.OnScraped(func(r *colly.Response) {
|
c.OnScraped(func(r *colly.Response) {
|
||||||
seasonMap := make(map[int]bool)
|
seasonMap := make(map[int]bool)
|
||||||
uniqueSeasons := []int{}
|
uniqueSeasons := []int{}
|
||||||
|
slog.Info("scraped seasons", "seasons", seasons)
|
||||||
for _, seasonNum := range seasons {
|
for _, seasonNum := range seasons {
|
||||||
if !seasonMap[seasonNum] {
|
if !seasonMap[seasonNum] {
|
||||||
seasonMap[seasonNum] = true
|
seasonMap[seasonNum] = true
|
||||||
@ -75,7 +75,7 @@ func ScrapeSeasons(ttImdb string) []Season {
|
|||||||
episodeCollector.Wait()
|
episodeCollector.Wait()
|
||||||
})
|
})
|
||||||
|
|
||||||
c.Visit("https://www.imdb.com/title/tt0903747/episodes")
|
c.Visit(fmt.Sprintf("https://www.imdb.com/title/%s/episodes", ttImdb))
|
||||||
c.Wait()
|
c.Wait()
|
||||||
|
|
||||||
return allSeasons
|
return allSeasons
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user