tvdb - auth_test.go
1 package tvdb_test
2
3 import (
4 "encoding/json"
5 "os"
6
7 "vimagination.zapto.org/tvdb"
8 )
9
10 var (
11 auth = tvdb.Auth{
12 APIKey: os.Getenv("apikey"),
13 UserKey: os.Getenv("userkey"),
14 Username: os.Getenv("username"),
15 }
16 conn *tvdb.Conn
17 )
18
19 func init() {
20 if auth.APIKey == "" {
21 f, err := os.Open("apikey") // json encoded data {"apikey":"APIKEY","username":"USERNAME","userkey":"USERKEY"}
22 if err != nil {
23 panic(err)
24 }
25 err = json.NewDecoder(f).Decode(&auth)
26 f.Close()
27 if err != nil {
28 panic(err)
29 }
30 }
31 }