From ce3510f2dca36b34eddaac33bcfe44362fb7b586 Mon Sep 17 00:00:00 2001 From: StalkR Date: Fri, 2 Aug 2024 15:22:57 +0200 Subject: [PATCH] season: fix lint: add comments to exported things, unexport seasonURL --- season.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/season.go b/season.go index e708a3b..e835235 100644 --- a/season.go +++ b/season.go @@ -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 } @@ -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)