mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Add temporary session id lookup on login first
This commit is contained in:
parent
ea3506b7f6
commit
b92eddc5d2
1 changed files with 17 additions and 18 deletions
|
|
@ -140,6 +140,23 @@ func freeFileName(filename string) (string, bool) {
|
||||||
func loadCrunchy() {
|
func loadCrunchy() {
|
||||||
out.SetProgress("Logging in")
|
out.SetProgress("Logging in")
|
||||||
|
|
||||||
|
tmpFilePath := filepath.Join(os.TempDir(), ".crunchy")
|
||||||
|
if _, statErr := os.Stat(tmpFilePath); !os.IsNotExist(statErr) {
|
||||||
|
body, err := os.ReadFile(tmpFilePath)
|
||||||
|
if err != nil {
|
||||||
|
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)
|
||||||
|
} 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.StopProgress("Logged in")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if configDir, err := os.UserConfigDir(); err == nil {
|
if configDir, err := os.UserConfigDir(); err == nil {
|
||||||
persistentFilePath := filepath.Join(configDir, "crunchyroll-go", "crunchy")
|
persistentFilePath := filepath.Join(configDir, "crunchyroll-go", "crunchy")
|
||||||
if _, statErr := os.Stat(persistentFilePath); statErr == nil {
|
if _, statErr := os.Stat(persistentFilePath); statErr == nil {
|
||||||
|
|
@ -171,24 +188,6 @@ func loadCrunchy() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpFilePath := filepath.Join(os.TempDir(), ".crunchy")
|
|
||||||
if _, statErr := os.Stat(tmpFilePath); !os.IsNotExist(statErr) {
|
|
||||||
body, err := os.ReadFile(tmpFilePath)
|
|
||||||
if err != nil {
|
|
||||||
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.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", body)
|
|
||||||
|
|
||||||
out.StopProgress("Logged in")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
out.StopProgress("To use this command, login first. Type `%s login -h` to get help", os.Args[0])
|
out.StopProgress("To use this command, login first. Type `%s login -h` to get help", os.Args[0])
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue