Пример #1
0
func Get(tvShowId int) ([]int, error) {
	tvs := tvshow{}
	_url := fmt.Sprintf("/tv/%d", tvShowId)
	err := internal.DoGetAndJsonUnmarshall(_url, &tvs)
	if err != nil {
		return nil, err
	}
	numbers := make([]int, len(tvs.Seasons))
	for i, season := range tvs.Seasons {
		numbers[i] = season.SeasonNumber
	}
	return numbers, nil
}
Пример #2
0
func Get(tvShowId int, seasonNumber int) (domain.TimeRange, error) {
	_season := season{}
	_url := fmt.Sprintf("/tv/%d/season/%d", tvShowId, seasonNumber)
	err := internal.DoGetAndJsonUnmarshall(_url, &_season)
	tr := domain.TimeRange{}
	if err != nil {
		return tr, err
	}
	eps := _season.Episodes
	if len(eps) == 0 {
		return tr, &myerrors.UnprocessableSeasonError{"No episodes for this season"}
	}
	start, err := parseAirDate(eps[0].AirDate)
	if err != nil {
		return tr, &myerrors.UnprocessableSeasonError{"Unparsable air date : " + eps[0].AirDate}
	}
	end, err := parseAirDate(eps[len(eps)-1].AirDate)
	if err != nil {
		return tr, &myerrors.UnprocessableSeasonError{"Unparsable air date : " + eps[len(eps)-1].AirDate}
	}
	tr = domain.TimeRange{start, end}
	return tr, nil

}