-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunrestrict.go
45 lines (38 loc) · 997 Bytes
/
unrestrict.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
package rd
import (
"encoding/json"
)
// Endpoints
const (
unrestrictUrl = apiBaseUrl + "/unrestrict/link"
)
type (
UnrestrictInfo struct {
ID string `json:"id"`
Filename string `json:"filename"`
MimeType string `json:"mimeType"`
Filesize int64 `json:"filesize"`
Link string `json:"link"`
Host string `json:"host"`
HostIcon string `json:"host_icon"`
Chunks int `json:"chunks"`
CRC int `json:"crc"`
Download string `json:"download"`
Streamable int `json:"streamable"`
}
UnrestrictService interface {
SimpleUnrestrict(link string) (info UnrestrictInfo, err error)
}
UnrestrictClient struct {
HTTPDoer
}
)
func (c *UnrestrictClient) SimpleUnrestrict(link string) (info UnrestrictInfo, err error) {
resp, err := httpPostForm(c, unrestrictUrl, map[string]string{"link": link})
if err != nil {
return info, err
}
defer resp.Body.Close()
err = json.NewDecoder(resp.Body).Decode(&info)
return info, err
}