Merge branch 'next/v3' into v3/feature/non-premium-support

This commit is contained in:
ByteDream 2022-06-10 16:04:25 +02:00 committed by GitHub
commit ae075ed4c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 1173 additions and 205 deletions

View file

@ -3,6 +3,7 @@ package crunchyroll
import (
"encoding/json"
"fmt"
"net/http"
"regexp"
"strconv"
"strings"
@ -75,6 +76,17 @@ type Episode struct {
StreamID string
}
// HistoryEpisode contains additional information about an episode if the account has watched or started to watch the episode.
type HistoryEpisode struct {
*Episode
DatePlayed time.Time `json:"date_played"`
ParentID string `json:"parent_id"`
ParentType MediaType `json:"parent_type"`
Playhead uint `json:"playhead"`
FullyWatched bool `json:"fully_watched"`
}
// EpisodeFromID returns an episode by its api id.
func EpisodeFromID(crunchy *Crunchyroll, id string) (*Episode, error) {
resp, err := crunchy.request(fmt.Sprintf("https://beta-api.crunchyroll.com/cms/v2/%s/episodes/%s?locale=%s&Signature=%s&Policy=%s&Key-Pair-Id=%s",
@ -83,7 +95,7 @@ func EpisodeFromID(crunchy *Crunchyroll, id string) (*Episode, error) {
crunchy.Locale,
crunchy.Config.Signature,
crunchy.Config.Policy,
crunchy.Config.KeyPairID))
crunchy.Config.KeyPairID), http.MethodGet)
if err != nil {
return nil, err
}