Feature: Added config file
This commit is contained in:
parent
0f5567efbb
commit
5fc793ac21
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
.vercel
|
||||
*.map
|
||||
config.yml
|
||||
|
|
6
config.example.yml
Normal file
6
config.example.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
# This is required for the API. See https://github.com/Nandaka/PixivUtil2/wiki#pixiv-login-using-cookie
|
||||
# Please keep this carefully, there is a risk of account theft if somebody got your cookie.
|
||||
# It is better to use a decoy account, instead of using your main account's cookie.
|
||||
PHPSESSID:
|
||||
|
||||
userAgent: Mozilla/5.0
|
29
configs/config.go
Normal file
29
configs/config.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package configs
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"gopkg.in/yaml.v3"
|
||||
"os"
|
||||
)
|
||||
|
||||
var Config embed.FS
|
||||
var Configs Conf
|
||||
|
||||
type Conf struct {
|
||||
PHPSESSID string `yaml:"PHPSESSID"`
|
||||
userAgent int `yaml:"userAgent"`
|
||||
}
|
||||
|
||||
func (conf *Conf) ReadConfig() {
|
||||
f, err := os.Open("config.yml")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
decoder := yaml.NewDecoder(f)
|
||||
err = decoder.Decode(conf)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue