Skip to content

Commit

Permalink
season: fix lint: add comments to exported things, unexport seasonURL
Browse files Browse the repository at this point in the history
  • Loading branch information
StalkR committed Aug 2, 2024
1 parent 3d28759 commit ce3510f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions season.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,27 @@ import (
"strconv"
)

// Episode represents a single episode from a TV series.
type Episode struct {
SeasonNumber, EpisodeNumber int
ImageURL, ID, Name string
}

// Season represents a season from a TV Series, with a list of episodes.
type Season struct {
ID string `json:",omitempty"`
SeasonNumber int `json:",omitempty"`
Episodes []Episode `json:",omitempty"`
}

const SeasonURL = "https://www.imdb.com/title/%s/episodes/?season=%d"
const seasonURL = "https://www.imdb.com/title/%s/episodes/?season=%d"

// NewSeason gets, parses and returns a Season by its ID and season number.
func NewSeason(c *http.Client, id string, season int) (*Season, error) {
if !ttRE.MatchString(id) {
return nil, ErrInvalidID
}
resp, err := c.Get(fmt.Sprintf(SeasonURL, id, season))
resp, err := c.Get(fmt.Sprintf(seasonURL, id, season))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -60,6 +63,7 @@ var (
seasonEpisodeEntryRE = regexp.MustCompile(`src="(https://m\.media-amazon\.com/images/[^"]*)" srcSet="[^"]*" sizes="[^"]*" width=".\d+"[^h]*[^r][^e][^f]f="/title/(tt.\d*)/\?ref_=ttep_ep(\d+)"[^"]*"([^"]*)"><`)
)

// Parse parses a Season from its page.
func (s *Season) Parse(c *http.Client, page []byte) error {
episodesMatch := seasonEpisodeEntryRE.FindAllSubmatch(page, -1)

Expand Down

0 comments on commit ce3510f

Please sign in to comment.