Documentation
ΒΆ
Index ΒΆ
- Constants
- func ParseBetaEpisodeURL(url string) (episodeId string, ok bool)
- func ParseBetaSeriesURL(url string) (seasonId string, ok bool)
- func ParseEpisodeURL(url string) (seriesName, title string, episodeNumber int, webId int, ok bool)deprecated
- func ParseVideoURL(url string) (seriesName string, ok bool)deprecated
- type Crunchyroll
- func (c *Crunchyroll) ExtractEpisodesFromUrl(url string, audio ...LOCALE) ([]*Episode, error)
- func (c *Crunchyroll) FindEpisodeByName(seriesName, episodeTitle string) ([]*Episode, error)
- func (c *Crunchyroll) FindVideoByName(seriesName string) (Video, error)deprecated
- func (c *Crunchyroll) IsCaching() bool
- func (c *Crunchyroll) ParseUrl(url string) (*Series, []*Episode, error)
- func (c *Crunchyroll) Search(query string, limit uint) (s []*Series, m []*Movie, err error)
- func (c *Crunchyroll) SetCaching(caching bool)
- type Downloader
- type Episode
- type Format
- type FormatType
- type LOCALE
- type Movie
- type MovieListing
- type Season
- type Series
- type Stream
- type Subtitle
- type Video
Constants ΒΆ
const ( JP LOCALE = "ja-JP" US = "en-US" LA = "es-419" ES = "es-ES" FR = "fr-FR" PT = "pt-PT" BR = "pt-BR" IT = "it-IT" DE = "de-DE" RU = "ru-RU" AR = "ar-SA" )
Variables ΒΆ
This section is empty.
Functions ΒΆ
func ParseBetaEpisodeURL ΒΆ
ParseBetaEpisodeURL tries to extract the episode id of the given crunchyroll beta url, pointing to an episode.
func ParseBetaSeriesURL ΒΆ
ParseBetaSeriesURL tries to extract the season id of the given crunchyroll beta url, pointing to a season.
func ParseEpisodeURL
deprecated
ParseEpisodeURL tries to extract the crunchyroll series name, title, episode number and web id out of the given crunchyroll url Note that the episode number can be misleading. For example if an episode has the episode number 23.5 (slime isekai) the episode number will be 235.
Deprecated: Crunchyroll classic urls are sometimes not safe to use, use ParseBetaEpisodeURL if possible since beta url are always safe to use. The method will stay in the library until only beta urls are supported by crunchyroll itself.
func ParseVideoURL
deprecated
ParseVideoURL tries to extract the crunchyroll series / movie name out of the given url.
Deprecated: Crunchyroll classic urls are sometimes not safe to use, use ParseBetaSeriesURL if possible since beta url are always safe to use. The method will stay in the library until only beta urls are supported by crunchyroll itself.
Types ΒΆ
type Crunchyroll ΒΆ
type Crunchyroll struct { // Client is the http.Client to perform all requests over. Client *http.Client // Context can be used to stop requests with Client and is context.Background by default. Context context.Context // Locale specifies in which language all results should be returned / requested. Locale LOCALE // SessionID is the crunchyroll session id which was used for authentication. SessionID string // Config stores parameters which are needed by some api calls. Config struct { TokenType string AccessToken string CountryCode string Premium bool Channel string Policy string Signature string KeyPairID string AccountID string ExternalID string MaturityRating string } // contains filtered or unexported fields }
func LoginWithCredentials ΒΆ
func LoginWithCredentials(user string, password string, locale LOCALE, client *http.Client) (*Crunchyroll, error)
LoginWithCredentials logs in via crunchyroll username or email and password.
func LoginWithSessionID ΒΆ
LoginWithSessionID logs in via a crunchyroll session id. Session ids are automatically generated as a cookie when visiting https://www.crunchyroll.com.
func (*Crunchyroll) ExtractEpisodesFromUrl ΒΆ
func (c *Crunchyroll) ExtractEpisodesFromUrl(url string, audio ...LOCALE) ([]*Episode, error)
ExtractEpisodesFromUrl extracts all episodes from an url. If audio is not empty, the episodes gets filtered after the given locale.
func (*Crunchyroll) FindEpisodeByName ΒΆ
func (c *Crunchyroll) FindEpisodeByName(seriesName, episodeTitle string) ([]*Episode, error)
FindEpisodeByName finds an episode by its crunchyroll series name and episode title. Use this in combination with ParseEpisodeURL and hand over the corresponding results to this function.
func (*Crunchyroll) FindVideoByName
deprecated
func (c *Crunchyroll) FindVideoByName(seriesName string) (Video, error)
FindVideoByName finds a Video (Season or Movie) by its name. Use this in combination with ParseVideoURL and hand over the corresponding results to this function.
Deprecated: Use Search instead. The first result sometimes isn't the correct one so this function is inaccurate in some cases. See https://github.com/crunchy-labs/crunchyroll-go/issues/22 for more information.
func (*Crunchyroll) IsCaching ΒΆ
func (c *Crunchyroll) IsCaching() bool
IsCaching returns if data gets cached or not. See SetCaching for more information.
func (*Crunchyroll) ParseUrl ΒΆ
func (c *Crunchyroll) ParseUrl(url string) (*Series, []*Episode, error)
ParseUrl parses the given url into a series or episode. The returning episode is a slice because non-beta urls have the same episode with different languages.
func (*Crunchyroll) Search ΒΆ
Search searches a query and returns all found series and movies within the given limit.
func (*Crunchyroll) SetCaching ΒΆ
func (c *Crunchyroll) SetCaching(caching bool)
SetCaching enables or disables internal caching of requests made. Caching is enabled by default. If it is disabled the already cached data still gets called. The best way to prevent this is to create a complete new Crunchyroll struct.
type Downloader ΒΆ
type Downloader struct { // The output is all written to Writer. Writer io.Writer // TempDir is the directory where the temporary segment files should be stored. // The files will be placed directly into the root of the directory. // If empty a random temporary directory on the system's default tempdir // will be created. // If the directory does not exist, it will be created. TempDir string // If DeleteTempAfter is true, the temp directory gets deleted afterwards. // Note that in case of a hard signal exit (os.Interrupt, ...) the directory // will NOT be deleted. In such situations try to catch the signal and // cancel Context. DeleteTempAfter bool // Context to control the download process with. // There is a tiny delay when canceling the context and the actual stop of the // process. So it is not recommend stopping the program immediately after calling // the cancel function. It's better when canceling it and then exit the program // when Format.Download throws an error. See the signal handling section in // cmd/crunchyroll-go/cmd/download.go for an example. Context context.Context // Goroutines is the number of goroutines to download segments with. Goroutines int // A method to call when a segment was downloaded. // Note that the segments are downloaded asynchronously (depending on the count of // Goroutines) and the function gets called asynchronously too, so for example it is // first called on segment 1, then segment 254, then segment 3 and so on. OnSegmentDownload func(segment *m3u8.MediaSegment, current, total int, file *os.File) error // If LockOnSegmentDownload is true, only one OnSegmentDownload function can be called at // once. Normally (because of the use of goroutines while downloading) multiple could get // called simultaneously. LockOnSegmentDownload bool // If FFmpegOpts is not nil, ffmpeg will be used to merge and convert files. // The given opts will be used as ffmpeg parameters while merging. // // If Writer is *os.File and -f (which sets the output format) is not specified, the output // format will be retrieved by its file ending. If this is not the case and -f is not given, // the output format will be mpegts / mpeg transport stream. // Execute 'ffmpeg -muxers' to see all available output formats. FFmpegOpts []string }
Downloader is used to download Format's
func NewDownloader ΒΆ
func NewDownloader(context context.Context, writer io.Writer, goroutines int, onSegmentDownload func(segment *m3u8.MediaSegment, current, total int, file *os.File) error) Downloader
NewDownloader creates a downloader with default settings which should fit the most needs.
type Episode ΒΆ
type Episode struct { ID string `json:"id"` ChannelID string `json:"channel_id"` SeriesID string `json:"series_id"` SeriesTitle string `json:"series_title"` SeriesSlugTitle string `json:"series_slug_title"` SeasonID string `json:"season_id"` SeasonTitle string `json:"season_title"` SeasonSlugTitle string `json:"season_slug_title"` SeasonNumber int `json:"season_number"` Episode string `json:"episode"` EpisodeNumber int `json:"episode_number"` SequenceNumber float64 `json:"sequence_number"` ProductionEpisodeID string `json:"production_episode_id"` Title string `json:"title"` SlugTitle string `json:"slug_title"` Description string `json:"description"` NextEpisodeID string `json:"next_episode_id"` NextEpisodeTitle string `json:"next_episode_title"` HDFlag bool `json:"hd_flag"` IsMature bool `json:"is_mature"` MatureBlocked bool `json:"mature_blocked"` EpisodeAirDate time.Time `json:"episode_air_date"` IsSubbed bool `json:"is_subbed"` IsDubbed bool `json:"is_dubbed"` IsClip bool `json:"is_clip"` SeoTitle string `json:"seo_title"` SeoDescription string `json:"seo_description"` SeasonTags []string `json:"season_tags"` AvailableOffline bool `json:"available_offline"` Slug string `json:"slug"` Images struct { Thumbnail [][]struct { Width int `json:"width"` Height int `json:"height"` Type string `json:"type"` Source string `json:"source"` } `json:"thumbnail"` } `json:"images"` DurationMS int `json:"duration_ms"` IsPremiumOnly bool `json:"is_premium_only"` ListingID string `json:"listing_id"` SubtitleLocales []LOCALE `json:"subtitle_locales"` Playback string `json:"playback"` AvailabilityNotes string `json:"availability_notes"` StreamID string // contains filtered or unexported fields }
Episode contains all information about an episode.
func EpisodeFromID ΒΆ
func EpisodeFromID(crunchy *Crunchyroll, id string) (*Episode, error)
EpisodeFromID returns an episode by its api id.
func (*Episode) AudioLocale ΒΆ
AudioLocale returns the audio locale of the episode. Every episode in a season (should) have the same audio locale, so if you want to get the audio locale of a season, just call this method on the first episode of the season.
type Format ΒΆ
type Format struct { ID string // FormatType represents if the format parent is an episode or a movie. FormatType FormatType Video *m3u8.Variant AudioLocale LOCALE Hardsub LOCALE Subtitles []*Subtitle // contains filtered or unexported fields }
Format contains detailed information about an episode video stream.
func (*Format) Download ΒΆ
func (f *Format) Download(downloader Downloader) error
Download downloads the Format with the via Downloader specified options.
func (*Format) InitVideo ΒΆ
InitVideo initializes the Format.Video completely. The Format.Video.Chunklist pointer is, by default, nil because an additional request must be made to receive its content. The request is not made when initializing a Format struct because it would probably cause an intense overhead since Format.Video.Chunklist is only used sometimes.
type FormatType ΒΆ
type FormatType string
const ( EPISODE FormatType = "episodes" MOVIE = "movies" )
type Movie ΒΆ
type Movie struct { Video // not generated when calling MovieFromID. MovieListingMetadata struct { AvailabilityNotes string `json:"availability_notes"` AvailableOffline bool `json:"available_offline"` DurationMS int `json:"duration_ms"` ExtendedDescription string `json:"extended_description"` FirstMovieID string `json:"first_movie_id"` IsDubbed bool `json:"is_dubbed"` IsMature bool `json:"is_mature"` IsPremiumOnly bool `json:"is_premium_only"` IsSubbed bool `json:"is_subbed"` MatureRatings []string `json:"mature_ratings"` MovieReleaseYear int `json:"movie_release_year"` SubtitleLocales []LOCALE `json:"subtitle_locales"` } `json:"movie_listing_metadata"` Playback string `json:"playback"` PromoDescription string `json:"promo_description"` PromoTitle string `json:"promo_title"` SearchMetadata struct { Score float64 `json:"score"` } // contains filtered or unexported fields }
Movie contains information about a movie.
func MovieFromID ΒΆ
func MovieFromID(crunchy *Crunchyroll, id string) (*Movie, error)
MovieFromID returns a movie by its api id.
func (*Movie) MovieListing ΒΆ
func (m *Movie) MovieListing() (movieListings []*MovieListing, err error)
MovieListing returns all videos corresponding with the movie.
type MovieListing ΒΆ
type MovieListing struct { ID string `json:"id"` Title string `json:"title"` Slug string `json:"slug"` SlugTitle string `json:"slug_title"` Description string `json:"description"` Images struct { Thumbnail [][]struct { Width int `json:"width"` Height int `json:"height"` Type string `json:"type"` Source string `json:"source"` } `json:"thumbnail"` } `json:"images"` DurationMS int `json:"duration_ms"` IsPremiumOnly bool `json:"is_premium_only"` ListeningID string `json:"listening_id"` IsMature bool `json:"is_mature"` AvailableOffline bool `json:"available_offline"` IsSubbed bool `json:"is_subbed"` IsDubbed bool `json:"is_dubbed"` Playback string `json:"playback"` AvailabilityNotes string `json:"availability_notes"` // contains filtered or unexported fields }
MovieListing contains information about something which is called movie listing. I don't know what this means thb.
func MovieListingFromID ΒΆ
func MovieListingFromID(crunchy *Crunchyroll, id string) (*MovieListing, error)
MovieListingFromID returns a movie listing by its api id.
func (*MovieListing) AudioLocale ΒΆ
func (ml *MovieListing) AudioLocale() (LOCALE, error)
AudioLocale is same as Episode.AudioLocale.
func (*MovieListing) Streams ΒΆ
func (ml *MovieListing) Streams() ([]*Stream, error)
Streams returns all streams which are available for the movie listing.
type Season ΒΆ
type Season struct { ID string `json:"id"` ChannelID string `json:"channel_id"` Title string `json:"title"` SlugTitle string `json:"slug_title"` SeriesID string `json:"series_id"` SeasonNumber int `json:"season_number"` IsComplete bool `json:"is_complete"` Description string `json:"description"` Keywords []string `json:"keywords"` SeasonTags []string `json:"season_tags"` IsMature bool `json:"is_mature"` MatureBlocked bool `json:"mature_blocked"` IsSubbed bool `json:"is_subbed"` IsDubbed bool `json:"is_dubbed"` IsSimulcast bool `json:"is_simulcast"` SeoTitle string `json:"seo_title"` SeoDescription string `json:"seo_description"` AvailabilityNotes string `json:"availability_notes"` // the locales are always empty, idk why this may change in the future AudioLocales []LOCALE SubtitleLocales []LOCALE // contains filtered or unexported fields }
Season contains information about an anime season.
func SeasonFromID ΒΆ
func SeasonFromID(crunchy *Crunchyroll, id string) (*Season, error)
SeasonFromID returns a season by its api id.
func (*Season) AudioLocale ΒΆ
AudioLocale returns the audio locale of the season.
type Series ΒΆ
type Series struct { Video PromoDescription string `json:"promo_description"` PromoTitle string `json:"promo_title"` AvailabilityNotes string `json:"availability_notes"` EpisodeCount int `json:"episode_count"` ExtendedDescription string `json:"extended_description"` IsDubbed bool `json:"is_dubbed"` IsMature bool `json:"is_mature"` IsSimulcast bool `json:"is_simulcast"` IsSubbed bool `json:"is_subbed"` MatureBlocked bool `json:"mature_blocked"` MatureRatings []string `json:"mature_ratings"` SeasonCount int `json:"season_count"` // not generated when calling SeriesFromID. SearchMetadata struct { Score float64 `json:"score"` } // contains filtered or unexported fields }
Series contains information about an anime series.
func SeriesFromID ΒΆ
func SeriesFromID(crunchy *Crunchyroll, id string) (*Series, error)
SeriesFromID returns a series by its api id.
type Stream ΒΆ
type Stream struct { HardsubLocale LOCALE AudioLocale LOCALE Subtitles []*Subtitle // contains filtered or unexported fields }
Stream contains information about all available video stream of an episode.
func StreamsFromID ΒΆ
func StreamsFromID(crunchy *Crunchyroll, id string) ([]*Stream, error)
StreamsFromID returns a stream by its api id.