-
Notifications
You must be signed in to change notification settings - Fork 0
/
nfo.go
49 lines (42 loc) · 1.11 KB
/
nfo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package xrel
import (
"io/ioutil"
"net/http"
)
/*
GetNFOByID returns PNG image data of a NFO file for a given release id.
Requires user or application OAuth2 authentication.
id The release id as obtained trough over methods.
isP2P Is the release a P2P release?
Please cache the file on your device. You may not modify the image in any way or hide the footer.
https://www.xrel.to/wiki/6438/api-nfo-release.html
https://www.xrel.to/wiki/6437/api-nfo-p2p-rls.html
*/
func GetNFOByID(id string, isP2P bool) ([]byte, error) {
var (
base64Image []byte
err error
)
requestURL := apiURL + "nfo/release.json?id="
if isP2P {
requestURL = apiURL + "nfo/p2p_rls.json?id="
}
requestURL = requestURL + id
client := http.DefaultClient
var request *http.Request
request, err = getOAuth2Request("GET", requestURL, nil)
if err == nil {
var response *http.Response
response, err = client.Do(request)
if err == nil {
err = checkResponse(response)
if err == nil {
base64Image, err = ioutil.ReadAll(response.Body)
if err == nil {
return base64Image, err
}
}
}
}
return base64Image, err
}