mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Merge branch 'next/v3' into v3/feature/encrypted-credentials
This commit is contained in:
commit
a20c70cd2b
23 changed files with 762 additions and 162 deletions
|
|
@ -5,8 +5,8 @@ import (
|
|||
"crypto/cipher"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"github.com/ByteDream/crunchyroll-go/v2"
|
||||
"github.com/ByteDream/crunchyroll-go/v2/utils"
|
||||
"github.com/ByteDream/crunchyroll-go/v3"
|
||||
"github.com/ByteDream/crunchyroll-go/v3/utils"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
|
|
@ -150,10 +150,10 @@ func loadCrunchy() {
|
|||
out.StopProgress("Failed to read login information: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if crunchy, err = crunchyroll.LoginWithSessionID(url.QueryEscape(string(body)), systemLocale(true), client); err != nil {
|
||||
out.Debug("Failed to login with temp session id: %w", err)
|
||||
if crunchy, err = crunchyroll.LoginWithEtpRt(url.QueryEscape(string(body)), systemLocale(true), client); err != nil {
|
||||
out.Debug("Failed to login with temp etp rt cookie: %v", err)
|
||||
} else {
|
||||
out.Debug("Logged in with session id %s. BLANK THIS LINE OUT IF YOU'RE ASKED TO POST THE DEBUG OUTPUT SOMEWHERE", body)
|
||||
out.Debug("Logged in with etp rt cookie %s. BLANK THIS LINE OUT IF YOU'RE ASKED TO POST THE DEBUG OUTPUT SOMEWHERE", body)
|
||||
|
||||
out.StopProgress("Logged in")
|
||||
return
|
||||
|
|
@ -170,6 +170,7 @@ func loadCrunchy() {
|
|||
}
|
||||
split := strings.SplitN(string(body), "\n", 2)
|
||||
if len(split) == 1 || split[1] == "" {
|
||||
<<<<<<< v3/feature/encrypted-credentials
|
||||
if strings.HasPrefix(split[0], "aes:") {
|
||||
encrypted := body[4:]
|
||||
|
||||
|
|
@ -213,14 +214,23 @@ func loadCrunchy() {
|
|||
}
|
||||
|
||||
if len(split) == 2 {
|
||||
=======
|
||||
split[0] = url.QueryEscape(split[0])
|
||||
if crunchy, err = crunchyroll.LoginWithEtpRt(split[0], systemLocale(true), client); err != nil {
|
||||
out.StopProgress(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
out.Debug("Logged in with etp rt cookie %s. BLANK THIS LINE OUT IF YOU'RE ASKED TO POST THE DEBUG OUTPUT SOMEWHERE", split[0])
|
||||
} else {
|
||||
>>>>>>> next/v3
|
||||
if crunchy, err = crunchyroll.LoginWithCredentials(split[0], split[1], systemLocale(true), client); err != nil {
|
||||
out.StopProgress(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
out.Debug("Logged in with session id %s. BLANK THIS LINE OUT IF YOU'RE ASKED TO POST THE DEBUG OUTPUT SOMEWHERE", crunchy.SessionID)
|
||||
// the session id is written to a temp file to reduce the amount of re-logging in.
|
||||
out.Debug("Logged in with etp rt cookie %s. BLANK THIS LINE OUT IF YOU'RE ASKED TO POST THE DEBUG OUTPUT SOMEWHERE", crunchy.EtpRt)
|
||||
// the etp rt is written to a temp file to reduce the amount of re-logging in.
|
||||
// it seems like that crunchyroll has also a little cooldown if a user logs in too often in a short time
|
||||
os.WriteFile(filepath.Join(os.TempDir(), ".crunchy"), []byte(crunchy.SessionID), 0600)
|
||||
os.WriteFile(filepath.Join(os.TempDir(), ".crunchy"), []byte(crunchy.EtpRt), 0600)
|
||||
}
|
||||
|
||||
out.StopProgress("Logged in")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue