mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Fix login not working with session id
This commit is contained in:
parent
2d28991a70
commit
382d19ee94
1 changed files with 8 additions and 11 deletions
|
|
@ -10,6 +10,7 @@ import (
|
|||
"net/url"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// LOCALE represents a locale / language.
|
||||
|
|
@ -143,17 +144,6 @@ func LoginWithSessionID(sessionID string, locale LOCALE, client *http.Client) (*
|
|||
data := jsonBody["data"].(map[string]interface{})
|
||||
|
||||
crunchy.Config.CountryCode = data["country_code"].(string)
|
||||
user := data["user"]
|
||||
if user == nil {
|
||||
return nil, fmt.Errorf("invalid session id, user is not logged in")
|
||||
}
|
||||
if user.(map[string]interface{})["premium"] == "" {
|
||||
crunchy.Config.Premium = false
|
||||
crunchy.Config.Channel = "-"
|
||||
} else {
|
||||
crunchy.Config.Premium = true
|
||||
crunchy.Config.Channel = "crunchyroll"
|
||||
}
|
||||
|
||||
var etpRt string
|
||||
for _, cookie := range resp.Cookies() {
|
||||
|
|
@ -206,6 +196,13 @@ func LoginWithSessionID(sessionID string, locale LOCALE, client *http.Client) (*
|
|||
}
|
||||
cms := jsonBody["cms"].(map[string]interface{})
|
||||
|
||||
if strings.Contains(cms["bucket"].(string), "crunchyroll") {
|
||||
crunchy.Config.Premium = true
|
||||
crunchy.Config.Channel = "crunchyroll"
|
||||
} else {
|
||||
crunchy.Config.Premium = false
|
||||
crunchy.Config.Channel = "-"
|
||||
}
|
||||
crunchy.Config.Policy = cms["policy"].(string)
|
||||
crunchy.Config.Signature = cms["signature"].(string)
|
||||
crunchy.Config.KeyPairID = cms["key_pair_id"].(string)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue