Documentation ¶
Index ¶
- Variables
- func IsStructureError(err error) (ok bool)
- func LocaleLanguage(locale crunchyroll.LOCALE) string
- func SubtitleByLocale(format *crunchyroll.Format, locale crunchyroll.LOCALE) (subtitle *crunchyroll.Subtitle, ok bool)
- func ValidateLocale(locale crunchyroll.LOCALE) bool
- type EpisodeStructure
- func (es *EpisodeStructure) EpisodeParent(episode *crunchyroll.Episode) (*crunchyroll.Season, error)
- func (es *EpisodeStructure) Episodes() ([]*crunchyroll.Episode, error)
- func (es *EpisodeStructure) GetEpisodeByFormat(format *crunchyroll.Format) (*crunchyroll.Episode, error)
- func (es *EpisodeStructure) GetEpisodeByURL(url string) (*crunchyroll.Episode, error)
- func (es *EpisodeStructure) OrderEpisodeByID() ([][]*crunchyroll.Episode, error)
- func (es *EpisodeStructure) OrderFormatsByEpisodeNumber() ([][]*crunchyroll.Format, error)
- type EpisodesByDuration
- type FormatStructure
- func (fs *FormatStructure) AvailableLocales(includeEmpty bool) (audioLocales []crunchyroll.LOCALE, subtitleLocales []crunchyroll.LOCALE, ...)
- func (fs *FormatStructure) FilterFormatsByAudio(locale crunchyroll.LOCALE) (f []*crunchyroll.Format, err error)
- func (fs *FormatStructure) FilterFormatsByLocales(audioLocale, subtitleLocale crunchyroll.LOCALE, hardsub bool) ([]*crunchyroll.Format, error)
- func (fs *FormatStructure) FilterFormatsBySubtitle(locale crunchyroll.LOCALE, hardsub bool) (f []*crunchyroll.Format, err error)
- func (fs *FormatStructure) FormatParent(format *crunchyroll.Format) (*crunchyroll.Stream, error)
- func (fs *FormatStructure) Formats() ([]*crunchyroll.Format, error)
- func (fs *FormatStructure) InitAll() error
- func (fs *FormatStructure) InitAllState() bool
- func (fs *FormatStructure) OrderFormatsByID() ([][]*crunchyroll.Format, error)
- type FormatsByResolution
- type MovieListingStructure
- type MovieListingsByDuration
- type SeasonStructure
- type StreamStructure
- type StructureError
- type VideoStructure
Constants ¶
This section is empty.
Variables ¶
var AllLocales = []crunchyroll.LOCALE{
crunchyroll.JP,
crunchyroll.US,
crunchyroll.LA,
crunchyroll.ES,
crunchyroll.FR,
crunchyroll.BR,
crunchyroll.IT,
crunchyroll.DE,
crunchyroll.RU,
crunchyroll.ME,
}
Functions ¶
func IsStructureError ¶ added in v1.1.0
func LocaleLanguage ¶
func LocaleLanguage(locale crunchyroll.LOCALE) string
LocaleLanguage returns the country by its locale
func SubtitleByLocale ¶
func SubtitleByLocale(format *crunchyroll.Format, locale crunchyroll.LOCALE) (subtitle *crunchyroll.Subtitle, ok bool)
SubtitleByLocale returns the subtitle of a crunchyroll.Format by its locale. Check the second ok return value if the format has this subtitle
func ValidateLocale ¶
func ValidateLocale(locale crunchyroll.LOCALE) bool
ValidateLocale validates if the given locale actually exist
Types ¶
type EpisodeStructure ¶
type EpisodeStructure struct { VideoStructure *StreamStructure // contains filtered or unexported fields }
EpisodeStructure fields are nearly same as FormatStructure
func NewEpisodeStructure ¶
func NewEpisodeStructure(episodes []*crunchyroll.Episode) *EpisodeStructure
NewEpisodeStructure returns a new EpisodeStructure, based on the given formats
func (*EpisodeStructure) EpisodeParent ¶
func (es *EpisodeStructure) EpisodeParent(episode *crunchyroll.Episode) (*crunchyroll.Season, error)
EpisodeParent returns the parent season of a stream (if present). If the stream or parent is not stored, an error will be returned
func (*EpisodeStructure) Episodes ¶
func (es *EpisodeStructure) Episodes() ([]*crunchyroll.Episode, error)
Episodes returns all stored episodes
func (*EpisodeStructure) GetEpisodeByFormat ¶
func (es *EpisodeStructure) GetEpisodeByFormat(format *crunchyroll.Format) (*crunchyroll.Episode, error)
GetEpisodeByFormat returns the episode to which the given format belongs to. If the format or the parent is not stored, an error will be returned
func (*EpisodeStructure) GetEpisodeByURL ¶ added in v1.1.0
func (es *EpisodeStructure) GetEpisodeByURL(url string) (*crunchyroll.Episode, error)
GetEpisodeByURL returns an episode by its url
func (*EpisodeStructure) OrderEpisodeByID ¶
func (es *EpisodeStructure) OrderEpisodeByID() ([][]*crunchyroll.Episode, error)
OrderEpisodeByID orders episodes by their ids
func (*EpisodeStructure) OrderFormatsByEpisodeNumber ¶
func (es *EpisodeStructure) OrderFormatsByEpisodeNumber() ([][]*crunchyroll.Format, error)
OrderFormatsByEpisodeNumber orders episodes by their episode number. Episode number 1 is on position 1 in the slice, number 2 on position 2, and so on. This was made intentionally because there is a chance that episodes with the episode number 0 are existing and position 0 in the slice is reserved for them. Therefore, if the first episode number is, for example, 20, the first 19 array entries will be nil
type EpisodesByDuration ¶
type EpisodesByDuration []*crunchyroll.Episode
EpisodesByDuration sorts episodes by their duration
func (EpisodesByDuration) Len ¶
func (ebd EpisodesByDuration) Len() int
func (EpisodesByDuration) Less ¶
func (ebd EpisodesByDuration) Less(i, j int) bool
func (EpisodesByDuration) Swap ¶
func (ebd EpisodesByDuration) Swap(i, j int)
type FormatStructure ¶
type FormatStructure struct {
// contains filtered or unexported fields
}
FormatStructure is the basic structure which every other structure implements. With it, and all other structures the api usage can be simplified magnificent
func NewFormatStructure ¶
func NewFormatStructure(formats []*crunchyroll.Format) *FormatStructure
NewFormatStructure returns a new FormatStructure, based on the given formats
func (*FormatStructure) AvailableLocales ¶
func (fs *FormatStructure) AvailableLocales(includeEmpty bool) (audioLocales []crunchyroll.LOCALE, subtitleLocales []crunchyroll.LOCALE, hardsubLocales []crunchyroll.LOCALE, err error)
AvailableLocales returns all available audio, subtitle and hardsub locales for all formats. If includeEmpty is given, locales with no value are included too
func (*FormatStructure) FilterFormatsByAudio ¶
func (fs *FormatStructure) FilterFormatsByAudio(locale crunchyroll.LOCALE) (f []*crunchyroll.Format, err error)
FilterFormatsByAudio returns all formats which have the given locale as their audio locale
func (*FormatStructure) FilterFormatsByLocales ¶
func (fs *FormatStructure) FilterFormatsByLocales(audioLocale, subtitleLocale crunchyroll.LOCALE, hardsub bool) ([]*crunchyroll.Format, error)
FilterFormatsByLocales returns all formats which have the given locales as their property. Hardsub is the same as in FormatStructure.FilterFormatsBySubtitle
func (*FormatStructure) FilterFormatsBySubtitle ¶
func (fs *FormatStructure) FilterFormatsBySubtitle(locale crunchyroll.LOCALE, hardsub bool) (f []*crunchyroll.Format, err error)
FilterFormatsBySubtitle returns all formats which have the given locale as their subtitle locale. Hardsub indicates if the subtitle should be shown on the video itself
func (*FormatStructure) FormatParent ¶
func (fs *FormatStructure) FormatParent(format *crunchyroll.Format) (*crunchyroll.Stream, error)
FormatParent returns the parent stream of a format (if present). If the format or parent is not stored, an error will be returned
func (*FormatStructure) Formats ¶
func (fs *FormatStructure) Formats() ([]*crunchyroll.Format, error)
Formats returns all stored formats
func (*FormatStructure) InitAll ¶
func (fs *FormatStructure) InitAll() error
InitAll recursive requests all given information. All functions of FormatStructure or other structs in this file which are executed after this have a much lesser chance to return any error, so the error return value of these functions can be pretty safely ignored. This function should only be called if you need to the access to any function of FormatStructure which returns a crunchyroll.Format (or an array of it). Re-calling this method can lead to heavy problems (believe me, it caused a simple bug and i've tried to fix it for several hours). Check FormatStructure.InitAllState if you can call this method without causing bugs
func (*FormatStructure) InitAllState ¶
func (fs *FormatStructure) InitAllState() bool
InitAllState returns FormatStructure.InitAll or FormatStructure.Formats was called. If so, all errors which are returned by functions of structs in this file can be safely ignored
func (*FormatStructure) OrderFormatsByID ¶
func (fs *FormatStructure) OrderFormatsByID() ([][]*crunchyroll.Format, error)
OrderFormatsByID loops through all stored formats and returns a 2d slice where a row represents an id and the column all formats which have this id
type FormatsByResolution ¶
type FormatsByResolution []*crunchyroll.Format
FormatsByResolution sorts formats after their resolution
func (FormatsByResolution) Len ¶
func (fbr FormatsByResolution) Len() int
func (FormatsByResolution) Less ¶
func (fbr FormatsByResolution) Less(i, j int) bool
func (FormatsByResolution) Swap ¶
func (fbr FormatsByResolution) Swap(i, j int)
type MovieListingStructure ¶
type MovieListingStructure struct { VideoStructure *StreamStructure // contains filtered or unexported fields }
MovieListingStructure fields are nearly same as FormatStructure
func NewMovieListingStructure ¶
func NewMovieListingStructure(movieListings []*crunchyroll.MovieListing) *MovieListingStructure
NewMovieListingStructure returns a new MovieListingStructure, based on the given formats
func (*MovieListingStructure) GetMovieListingByFormat ¶
func (ml *MovieListingStructure) GetMovieListingByFormat(format *crunchyroll.Format) (*crunchyroll.MovieListing, error)
GetMovieListingByFormat returns the movie listing to which the given format belongs to. If the format or the parent is not stored, an error will be returned
func (*MovieListingStructure) MovieListings ¶
func (ml *MovieListingStructure) MovieListings() ([]*crunchyroll.MovieListing, error)
MovieListings returns all stored movie listings
type MovieListingsByDuration ¶
type MovieListingsByDuration []*crunchyroll.MovieListing
MovieListingsByDuration sorts movie listings by their duration
func (MovieListingsByDuration) Len ¶
func (mlbd MovieListingsByDuration) Len() int
func (MovieListingsByDuration) Less ¶
func (mlbd MovieListingsByDuration) Less(i, j int) bool
func (MovieListingsByDuration) Swap ¶
func (mlbd MovieListingsByDuration) Swap(i, j int)
type SeasonStructure ¶
type SeasonStructure struct { *EpisodeStructure // contains filtered or unexported fields }
SeasonStructure fields are nearly same as FormatStructure
func NewSeasonStructure ¶
func NewSeasonStructure(seasons []*crunchyroll.Season) *SeasonStructure
NewSeasonStructure returns a new SeasonStructure, based on the given formats
func (*SeasonStructure) Seasons ¶
func (ss *SeasonStructure) Seasons() ([]*crunchyroll.Season, error)
Seasons returns all stored seasons
type StreamStructure ¶
type StreamStructure struct { *FormatStructure // contains filtered or unexported fields }
StreamStructure fields are nearly same as FormatStructure
func NewStreamStructure ¶
func NewStreamStructure(streams []*crunchyroll.Stream) *StreamStructure
NewStreamStructure returns a new StreamStructure, based on the given formats
func (*StreamStructure) StreamParent ¶
func (ss *StreamStructure) StreamParent(stream *crunchyroll.Stream) (crunchyroll.Video, error)
StreamParent returns the parent video (type crunchyroll.Series or crunchyroll.Movie) of a stream (if present). If the stream or parent is not stored, an error will be returned
func (*StreamStructure) Streams ¶
func (ss *StreamStructure) Streams() ([]*crunchyroll.Stream, error)
Streams returns all stored streams
type StructureError ¶ added in v1.1.0
type StructureError struct {
// contains filtered or unexported fields
}
StructureError is the error type which is thrown whenever a structure fails to receive information (formats, episodes, ...) from the api endpoint
type VideoStructure ¶
type VideoStructure interface{}
VideoStructure is an interface which is implemented by EpisodeStructure and MovieListingStructure