Documentation
¶
Overview ¶
Package cmoresearch implements a client for C More's search service.
API Documentation ¶
https://cmore-search.b17g.services/docs/
Usage ¶
A small usage example:
package main import ( "context" "fmt" "net/url" cmoresearch "github.com/TV4/cmoresearch-go" ) func main() { client := cmoresearch.NewClient() res, err := client.Search( context.Background(), url.Values{ "device_type": {"tve_web"}, "lang": {"sv"}, "site": {"cmore.se"}, "brand_id": {"34515"}, "season": {"1"}, "sort_by": {"episode_number"}, "order": {"asc"}, "page_size": {"3"}, }, ) if err != nil { fmt.Println(err) return } for _, hit := range res.Hits { if a, ok := hit.(*cmoresearch.Asset); ok { fmt.Printf("%s S%02dE%02d\n", a.Brand.TitleSv, a.Season.Number, a.EpisodeNumber) } } }
Output:
Solsidan S01E01 Solsidan S01E02 Solsidan S01E03
Index ¶
- Variables
- func SetAppName(appName string) func(*Client)
- func SetBaseURL(rawurl string) func(*Client)
- func SetDebugLogf(logf func(format string, v ...interface{})) func(*Client)
- func SetHTTPClient(hc *http.Client) func(*Client)
- func SetRequestID(requestID string) func(*http.Request)
- type APIError
- type Asset
- type Brand
- type Client
- type Credit
- type Event
- type ExternalReference
- type Genre
- type Hit
- type HitSubset
- type Image
- type Keyword
- type LocalizedImage
- type LocationRestrictions
- type LocationRights
- type Meta
- type OriginalTitle
- type ParentalRating
- type PublicationRights
- type Response
- type Season
- type Series
- type Tags
- type Team
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTypeMissing is returned when a search hit has an empty type field ErrTypeMissing = errors.New("type missing") // ErrContentTypeNotJSON is returned if a response does not have Content-Type application/json ErrContentTypeNotJSON = errors.New("Content-Type not JSON") // ErrInvalidBaseURL is returned if the client has been configured with an invalid base URL ErrInvalidBaseURL = errors.New("invalid base URL") )
Functions ¶
func SetAppName ¶
SetAppName is an option to set the value used in the client parameter sent to cmore-search.
func SetBaseURL ¶
SetBaseURL is an option to set a custom URL to the search service when creating a new Search instance.
func SetDebugLogf ¶
SetDebugLogf is an option to set a debug logger when creating a new client. If set the client will log requests using this logger, for debug uses.
func SetHTTPClient ¶
SetHTTPClient is an option to set a custom HTTP client when creating a new Search instance.
func SetRequestID ¶
SetRequestID is an option for Search to set the X-Request-Id header on the search request.
Types ¶
type Asset ¶
type Asset struct { Arena string `json:"arena"` AwayTeam Team `json:"awayteam"` Brand Brand `json:"brand"` Cinemascope Image `json:"cinemascope"` ContentAPIID string `json:"content_api_id"` ContentAPISeasonID string `json:"content_api_season_id"` ContentAPISeriesID string `json:"content_api_series_id"` ContentSource string `json:"content_source"` Country []string `json:"country"` Credits []Credit `json:"credits"` DRMRestrictions bool `json:"drm_restrictions"` DescriptionExtendedDa string `json:"description_extended_da"` DescriptionExtendedFi string `json:"description_extended_fi"` DescriptionExtendedNb string `json:"description_extended_nb"` DescriptionExtendedSv string `json:"description_extended_sv"` DescriptionLongDa string `json:"description_long_da"` DescriptionLongFi string `json:"description_long_fi"` DescriptionLongNb string `json:"description_long_nb"` DescriptionLongSv string `json:"description_long_sv"` DescriptionMediumDa string `json:"description_medium_da"` DescriptionMediumFi string `json:"description_medium_fi"` DescriptionMediumNb string `json:"description_medium_nb"` DescriptionMediumSv string `json:"description_medium_sv"` DescriptionShortDa string `json:"description_short_da"` DescriptionShortFi string `json:"description_short_fi"` DescriptionShortNb string `json:"description_short_nb"` DescriptionShortSv string `json:"description_short_sv"` DescriptionTinyDa string `json:"description_tiny_da"` DescriptionTinyFi string `json:"description_tiny_fi"` DescriptionTinyNb string `json:"description_tiny_nb"` DescriptionTinySv string `json:"description_tiny_sv"` Duration int `json:"duration"` EpisodeNumber int `json:"episode_number"` Events []Event `json:"events"` ExternalReferences []ExternalReference `json:"external_references"` FifteenBySeven Image `json:"fifteen_by_seven"` FourByThree Image `json:"four_by_three"` GenreDescriptionDa string `json:"genre_description_da"` GenreDescriptionFi string `json:"genre_description_fi"` GenreDescriptionNb string `json:"genre_description_nb"` GenreDescriptionSv string `json:"genre_description_sv"` Genres []Genre `json:"genres"` HomeTeam Team `json:"hometeam"` ItemsPublished bool `json:"items_published"` KeywordsDa []Keyword `json:"keywords_da"` KeywordsFi []Keyword `json:"keywords_fi"` KeywordsNb []Keyword `json:"keywords_nb"` KeywordsSv []Keyword `json:"keywords_sv"` Landscape Image `json:"landscape"` League string `json:"league"` LeagueDa string `json:"league_da"` LeagueFi string `json:"league_fi"` LeagueNb string `json:"league_nb"` LeagueSv string `json:"league_sv"` Live bool `json:"live"` LiveEventEnd time.Time `json:"live_event_end"` LogoAwayTeam Image `json:"logoawayteam"` LogoHomeTeam Image `json:"logohometeam"` MLTNIDs []string `json:"mlt_nids"` OriginalTitle OriginalTitle `json:"original_title"` ParentVideoID string `json:"parent_video_id"` ParentalRatings []ParentalRating `json:"parental_ratings"` Poster Image `json:"poster"` ProductionYear string `json:"production_year"` PublicationRights PublicationRights `json:"publication_rights"` Season Season `json:"season"` SpokenLanguages []string `json:"spoken_languages"` Studio string `json:"studio"` Tags Tags `json:"tags"` Timestamp string `json:"timestamp"` TitleDa string `json:"title_da"` TitleFi string `json:"title_fi"` TitleNb string `json:"title_nb"` TitleSv string `json:"title_sv"` Type string `json:"type"` VMANID string `json:"vman_id"` VideoID string `json:"video_id"` // contains filtered or unexported fields }
Asset is an asset hit returned by the search service.
type Brand ¶
type Brand struct { Cinemascope Image `json:"cinemascope"` Country []string `json:"country"` DescriptionExtendedDa string `json:"description_extended_da"` DescriptionExtendedFi string `json:"description_extended_fi"` DescriptionExtendedNb string `json:"description_extended_nb"` DescriptionExtendedSv string `json:"description_extended_sv"` DescriptionLongDa string `json:"description_long_da"` DescriptionLongFi string `json:"description_long_fi"` DescriptionLongNb string `json:"description_long_nb"` DescriptionLongSv string `json:"description_long_sv"` DescriptionMediumDa string `json:"description_medium_da"` DescriptionMediumFi string `json:"description_medium_fi"` DescriptionMediumNb string `json:"description_medium_nb"` DescriptionMediumSv string `json:"description_medium_sv"` DescriptionShortDa string `json:"description_short_da"` DescriptionShortFi string `json:"description_short_fi"` DescriptionShortNb string `json:"description_short_nb"` DescriptionShortSv string `json:"description_short_sv"` DescriptionTinyDa string `json:"description_tiny_da"` DescriptionTinyFi string `json:"description_tiny_fi"` DescriptionTinyNb string `json:"description_tiny_nb"` DescriptionTinySv string `json:"description_tiny_sv"` ExternalReferences []ExternalReference `json:"external_references"` FifteenBySeven Image `json:"fifteen_by_seven"` FourByThree Image `json:"four_by_three"` GenreDescriptionDa string `json:"genre_description_da"` GenreDescriptionFi string `json:"genre_description_fi"` GenreDescriptionNb string `json:"genre_description_nb"` GenreDescriptionSv string `json:"genre_description_sv"` Genres []Genre `json:"genres"` ID string `json:"id"` Landscape Image `json:"landscape"` Poster Image `json:"poster"` Studio string `json:"studio"` TitleDa string `json:"title_da"` TitleFi string `json:"title_fi"` TitleNb string `json:"title_nb"` TitleSv string `json:"title_sv"` }
Brand is the brand of an asset, e.g. Idol or Harry Potter.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client for the search service.
func (*Client) Search ¶
func (c *Client) Search(ctx context.Context, query url.Values, options ...func(r *http.Request)) (Response, error)
Search performs a search and returns the response. An error is returned if there is an error while setting up or sending the request, but also if the response status is not HTTP 200 OK or the response content is not JSON.
type Credit ¶
type Credit struct { Function string `json:"function"` NID string `json:"nid"` Name string `json:"name"` Rolename string `json:"rolename"` }
Credit represents one entry in the credit list for an asset.
type Event ¶
type Event struct { Site string `json:"site"` DeviceTypes []string `json:"device_types"` ProductGroups []string `json:"product_groups"` Products []string `json:"products"` StartTime time.Time `json:"start_time"` EndTime time.Time `json:"end_time"` PublishTime time.Time `json:"publish_time"` LivePublished bool `json:"live_published"` OnDemandPublished bool `json:"on_demand_published"` }
Event contains publication rights for an asset.
type ExternalReference ¶
type ExternalReference struct { Locator string `json:"locator"` Type string `json:"type"` Value string `json:"value"` }
ExternalReference is a reference to additional information contained in a different system.
type Genre ¶
Genre is the main and sub genre inforamtion for an asset, e.g. Main: Horror, Sub [Action, Drama, Romance]
type Hit ¶
type Hit interface {
Subset() *HitSubset
}
Hit is a search hit. It holds e.g. Asset or Series.
type HitSubset ¶
type HitSubset struct { ID string `json:"id"` Type string `json:"type"` Cinemascope Image `json:"cinemascope"` ContentSource string `json:"content_source"` Country []string `json:"country"` Credits []Credit `json:"credits"` DescriptionExtendedDa string `json:"description_extended_da"` DescriptionExtendedFi string `json:"description_extended_fi"` DescriptionExtendedNb string `json:"description_extended_nb"` DescriptionExtendedSv string `json:"description_extended_sv"` DescriptionLongDa string `json:"description_long_da"` DescriptionLongFi string `json:"description_long_fi"` DescriptionLongNb string `json:"description_long_nb"` DescriptionLongSv string `json:"description_long_sv"` DescriptionMediumDa string `json:"description_medium_da"` DescriptionMediumFi string `json:"description_medium_fi"` DescriptionMediumNb string `json:"description_medium_nb"` DescriptionMediumSv string `json:"description_medium_sv"` DescriptionShortDa string `json:"description_short_da"` DescriptionShortFi string `json:"description_short_fi"` DescriptionShortNb string `json:"description_short_nb"` DescriptionShortSv string `json:"description_short_sv"` DescriptionTinyDa string `json:"description_tiny_da"` DescriptionTinyFi string `json:"description_tiny_fi"` DescriptionTinyNb string `json:"description_tiny_nb"` DescriptionTinySv string `json:"description_tiny_sv"` Events []Event `json:"events"` ExternalReferences []ExternalReference `json:"external_references"` FifteenBySeven Image `json:"fifteen_by_seven"` FourByThree Image `json:"four_by_three"` GenreDescriptionDa string `json:"genre_description_da"` GenreDescriptionFi string `json:"genre_description_fi"` GenreDescriptionNb string `json:"genre_description_nb"` GenreDescriptionSv string `json:"genre_description_sv"` Genres []Genre `json:"genres"` KeywordsDa []Keyword `json:"keywords_da"` KeywordsFi []Keyword `json:"keywords_fi"` KeywordsNb []Keyword `json:"keywords_nb"` KeywordsSv []Keyword `json:"keywords_sv"` Landscape Image `json:"landscape"` Poster Image `json:"poster"` SpokenLanguages []string `json:"spoken_languages"` Studio string `json:"studio"` Tags Tags `json:"tags"` Timestamp string `json:"timestamp"` TitleDa string `json:"title_da"` TitleFi string `json:"title_fi"` TitleNb string `json:"title_nb"` TitleSv string `json:"title_sv"` }
HitSubset contains the subset of fields in common between different hit types (*Series and *Asset for now)
type Image ¶
type Image struct { Caption string `json:"caption"` Copyright string `json:"copyright"` Localizations []LocalizedImage `json:"localizations"` URL string `json:"url"` }
Image is the image attribute for an asset. It may contain localizations.
type LocalizedImage ¶
type LocalizedImage struct { Caption string `json:"caption"` Copyright string `json:"copyright"` Language string `json:"language"` URL string `json:"url"` }
LocalizedImage is a localized image.
type LocationRestrictions ¶
type LocationRestrictions struct {
IncludeCountries []string `json:"include_countries"`
}
LocationRestrictions contains restrictions by location.
type LocationRights ¶
type LocationRights struct { LocationRestrictions LocationRestrictions `json:"location_restrictions"` Product string `json:"product"` }
LocationRights contains rights based on location.
type OriginalTitle ¶
type OriginalTitle struct { Language string `json:"language"` Text string `json:"text"` Type string `json:"type"` }
OriginalTitle is the title of an asset in the original language.
type ParentalRating ¶
type ParentalRating struct { Country string `json:"country"` System string `json:"system"` Value string `json:"value"` }
ParentalRating is a parental rating of an asset for a given country and rating system.
type PublicationRights ¶
type PublicationRights struct {
LocationRights LocationRights `json:"location_rights"`
}
PublicationRights contain location rights for an asset.
type Season ¶
type Season struct { BroadcastingInfoDa string `json:"broadcasting_info_da"` BroadcastingInfoNb string `json:"broadcasting_info_nb"` BroadcastingInfoSv string `json:"broadcasting_info_sv"` Cinemascope Image `json:"cinemascope"` Country []string `json:"country"` DescriptionExtendedDa string `json:"description_extended_da"` DescriptionExtendedFi string `json:"description_extended_fi"` DescriptionExtendedNb string `json:"description_extended_nb"` DescriptionExtendedSv string `json:"description_extended_sv"` DescriptionLongDa string `json:"description_long_da"` DescriptionLongFi string `json:"description_long_fi"` DescriptionLongNb string `json:"description_long_nb"` DescriptionLongSv string `json:"description_long_sv"` DescriptionMediumDa string `json:"description_medium_da"` DescriptionMediumFi string `json:"description_medium_fi"` DescriptionMediumNb string `json:"description_medium_nb"` DescriptionMediumSv string `json:"description_medium_sv"` DescriptionShortDa string `json:"description_short_da"` DescriptionShortFi string `json:"description_short_fi"` DescriptionShortNb string `json:"description_short_nb"` DescriptionShortSv string `json:"description_short_sv"` DescriptionTinyDa string `json:"description_tiny_da"` DescriptionTinyFi string `json:"description_tiny_fi"` DescriptionTinyNb string `json:"description_tiny_nb"` DescriptionTinySv string `json:"description_tiny_sv"` ExternalReferences []ExternalReference `json:"external_references"` FifteenBySeven Image `json:"fifteen_by_seven"` FourByThree Image `json:"four_by_three"` GenreDescriptionDa string `json:"genre_description_da"` GenreDescriptionFi string `json:"genre_description_fi"` GenreDescriptionNb string `json:"genre_description_nb"` GenreDescriptionSv string `json:"genre_description_sv"` Genres []Genre `json:"genres"` ID string `json:"id"` Landscape Image `json:"landscape"` Number int `json:"season_number"` NumberOfEpisodes int `json:"number_of_episodes"` Poster Image `json:"poster"` Studio string `json:"studio"` TitleDa string `json:"title_da"` TitleFi string `json:"title_fi"` TitleNb string `json:"title_nb"` TitleSv string `json:"title_sv"` }
Season is a season of an asset, e.g. "Idol season 2".
type Series ¶
type Series struct { BrandID string `json:"brand_id"` Cinemascope Image `json:"cinemascope"` ContentSource string `json:"content_source"` ContentAPISeriesID string `json:"content_api_series_id"` Country []string `json:"country"` Credits []Credit `json:"credits"` DescriptionExtendedDa string `json:"description_extended_da"` DescriptionExtendedFi string `json:"description_extended_fi"` DescriptionExtendedNb string `json:"description_extended_nb"` DescriptionExtendedSv string `json:"description_extended_sv"` DescriptionLongDa string `json:"description_long_da"` DescriptionLongFi string `json:"description_long_fi"` DescriptionLongNb string `json:"description_long_nb"` DescriptionLongSv string `json:"description_long_sv"` DescriptionMediumDa string `json:"description_medium_da"` DescriptionMediumFi string `json:"description_medium_fi"` DescriptionMediumNb string `json:"description_medium_nb"` DescriptionMediumSv string `json:"description_medium_sv"` DescriptionShortDa string `json:"description_short_da"` DescriptionShortFi string `json:"description_short_fi"` DescriptionShortNb string `json:"description_short_nb"` DescriptionShortSv string `json:"description_short_sv"` DescriptionTinyDa string `json:"description_tiny_da"` DescriptionTinyFi string `json:"description_tiny_fi"` DescriptionTinyNb string `json:"description_tiny_nb"` DescriptionTinySv string `json:"description_tiny_sv"` Events []Event `json:"events"` ExternalReferences []ExternalReference `json:"external_references"` FifteenBySeven Image `json:"fifteen_by_seven"` FourByThree Image `json:"four_by_three"` GenreDescriptionDa string `json:"genre_description_da"` GenreDescriptionFi string `json:"genre_description_fi"` GenreDescriptionNb string `json:"genre_description_nb"` GenreDescriptionSv string `json:"genre_description_sv"` Genres []Genre `json:"genres"` ID string `json:"id"` KeywordsDa []Keyword `json:"keywords_da"` KeywordsFi []Keyword `json:"keywords_fi"` KeywordsNb []Keyword `json:"keywords_nb"` KeywordsSv []Keyword `json:"keywords_sv"` Landscape Image `json:"landscape"` ParentalRatings []ParentalRating `json:"parental_ratings"` Poster Image `json:"poster"` Scripted bool `json:"scripted"` Seasons []int `json:"seasons"` SeasonsDk []int `json:"seasons_cmore_dk"` SeasonsFi []int `json:"seasons_cmore_fi"` SeasonsNo []int `json:"seasons_cmore_no"` SeasonsSe []int `json:"seasons_cmore_se"` SpokenLanguages []string `json:"spoken_languages"` Studio string `json:"studio"` Tags Tags `json:"tags"` Timestamp string `json:"timestamp"` TitleDa string `json:"title_da"` TitleFi string `json:"title_fi"` TitleNb string `json:"title_nb"` TitleSv string `json:"title_sv"` Type string `json:"type"` // contains filtered or unexported fields }
Series is an series hit returned by the search service.