Load ...
()
| 402 | |
| 403 | // Load ... |
| 404 | func (cfg *CookieConfig) Load() (cookie string, err error) { |
| 405 | if cfg.BilibiliCookie != "" { |
| 406 | cookie = cfg.BilibiliCookie |
| 407 | return |
| 408 | } |
| 409 | if file.IsNotExist(cfg.file) { |
| 410 | err = errors.New("no cookie config") |
| 411 | return |
| 412 | } |
| 413 | reader, err := os.Open(cfg.file) |
| 414 | if err != nil { |
| 415 | return |
| 416 | } |
| 417 | defer reader.Close() |
| 418 | err = json.NewDecoder(reader).Decode(cfg) |
| 419 | cookie = cfg.BilibiliCookie |
| 420 | return |
| 421 | } |
| 422 | |
| 423 | // Save ... |
| 424 | func (cfg *CookieConfig) Save() (err error) { |
no outgoing calls
no test coverage detected