1- package main
1+ package scraper
22
33import (
44 "fmt"
99 log "github.com/sirupsen/logrus"
1010)
1111
12- // scrapeGame scrapes a game from j-archive.com
12+ // scrapeGameClues scrapes a game from j-archive.com.
1313func scrapeGameClues (gameID int64 ) (map [int64 ]* mods.Clue , map [int64 ]string ) {
1414 clueMap := map [int64 ]* mods.Clue {}
1515 clueStrings := map [int64 ]string {}
@@ -34,6 +34,7 @@ func scrapeGameClues(gameID int64) (map[int64]*mods.Clue, map[int64]string) {
3434 clueStrings [clueId ] = cid
3535 })
3636
37+ // collect and parse the categories for single jepp
3738 c .OnHTML ("div[id=jeopardy_round]" , func (e * colly.HTMLElement ) {
3839 cc := []string {}
3940 e .ForEach ("td.category_name" , func (_ int , el * colly.HTMLElement ) {
@@ -42,6 +43,7 @@ func scrapeGameClues(gameID int64) (map[int64]*mods.Clue, map[int64]string) {
4243 cats [mods .Jeopardy ] = append (cats [mods .Jeopardy ], cc ... )
4344 })
4445
46+ // collect and parse the categories for double jepp
4547 c .OnHTML ("div[id=double_jeopardy_round]" , func (e * colly.HTMLElement ) {
4648 cc := []string {}
4749 e .ForEach ("td.category_name" , func (_ int , el * colly.HTMLElement ) {
@@ -50,6 +52,7 @@ func scrapeGameClues(gameID int64) (map[int64]*mods.Clue, map[int64]string) {
5052 cats [mods .DoubleJeopardy ] = append (cats [mods .DoubleJeopardy ], cc ... )
5153 })
5254
55+ // collect and parse the categories for final jepp
5356 c .OnHTML ("div[id=final_jeopardy_round]" , func (e * colly.HTMLElement ) {
5457 cc := []string {}
5558 e .ForEach ("td.category_name" , func (_ int , el * colly.HTMLElement ) {
@@ -81,7 +84,7 @@ func scrapeAndFillCluesForGame(db *mods.JeppDB, gid int64) int {
8184
8285 for clueID , clue := range clues {
8386 actual , err := mods .GetCategoryByName (cats [clueID ])
84- if err != nil {
87+ if actual != nil {
8588 clue .CategoryID = actual .CategoryID
8689 continue
8790 }
0 commit comments