Daily Deviations
This commit is contained in:
parent
8f645d7ccb
commit
cec788554a
@ -15,7 +15,7 @@ type Comments struct {
|
|||||||
Thread []struct {
|
Thread []struct {
|
||||||
Replies, Likes int
|
Replies, Likes int
|
||||||
ID int `json:"commentId"`
|
ID int `json:"commentId"`
|
||||||
Parent int `json:"ParrentId"`
|
Parent int `json:"parentId"`
|
||||||
|
|
||||||
Posted time
|
Posted time
|
||||||
Author bool `json:"isAuthorHighlited"`
|
Author bool `json:"isAuthorHighlited"`
|
||||||
|
@ -97,10 +97,12 @@ func UrlFromMedia(m media) string {
|
|||||||
url.WriteString("image")
|
url.WriteString("image")
|
||||||
url.WriteString(".gif")
|
url.WriteString(".gif")
|
||||||
}
|
}
|
||||||
|
if len(m.Token) > 0 {
|
||||||
url.WriteString("?token=")
|
url.WriteString("?token=")
|
||||||
url.WriteString(m.Token[0])
|
url.WriteString(m.Token[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return url.String()
|
return url.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
44
misc.go
44
misc.go
@ -115,10 +115,27 @@ func AEmedia(name string, t rune) (string, error) {
|
|||||||
return "", errors.New("User not exists")
|
return "", errors.New("User not exists")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* DAILY DEVIATIONS */
|
||||||
|
type DailyDeviations struct {
|
||||||
|
HasMore bool
|
||||||
|
Strips []struct {
|
||||||
|
Codename, Title string
|
||||||
|
TitleType string
|
||||||
|
Deviations []Deviation
|
||||||
|
}
|
||||||
|
Deviations []Deviation
|
||||||
|
}
|
||||||
|
|
||||||
|
func DailyDeviationsFunc(page int) (dd DailyDeviations) {
|
||||||
|
ujson("dabrowse/networkbar/rfy/deviations?page="+strconv.Itoa(page), &dd)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
/* SEARCH */
|
/* SEARCH */
|
||||||
type Search struct {
|
type Search struct {
|
||||||
Total int `json:"estTotal"`
|
Total int `json:"estTotal"`
|
||||||
Pages int // only for 'a' and 'g' scope.
|
Pages int // only for 'a' and 'g' scope.
|
||||||
|
HasMore bool
|
||||||
Results []Deviation `json:"deviations,results"`
|
Results []Deviation `json:"deviations,results"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,10 +187,11 @@ func SearchFunc(query string, page int, scope rune, user ...string) (ss Search,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* PUPPY aka DeviantArt API */
|
/* PUPPY aka DeviantArt API */
|
||||||
func puppy(data string) (string, error) {
|
|
||||||
// получение или обновление токена
|
// получение или обновление токена
|
||||||
update := func() (string, string, error) {
|
|
||||||
var cookie string
|
var cookie string
|
||||||
|
var token string
|
||||||
|
|
||||||
|
func UpdateCSRF() error {
|
||||||
if cookie == "" {
|
if cookie == "" {
|
||||||
req := request("https://www.deviantart.com/_puppy")
|
req := request("https://www.deviantart.com/_puppy")
|
||||||
|
|
||||||
@ -184,24 +202,14 @@ func puppy(data string) (string, error) {
|
|||||||
|
|
||||||
req := request("https://www.deviantart.com", cookie)
|
req := request("https://www.deviantart.com", cookie)
|
||||||
if req.Status != 200 {
|
if req.Status != 200 {
|
||||||
return "", "", errors.New(req.Body)
|
return errors.New(req.Body)
|
||||||
}
|
}
|
||||||
|
token = req.Body[strings.Index(req.Body, "window.__CSRF_TOKEN__ = '")+25 : strings.Index(req.Body, "window.__XHR_LOCAL__")-3]
|
||||||
return cookie, req.Body[strings.Index(req.Body, "window.__CSRF_TOKEN__ = '")+25 : strings.Index(req.Body, "window.__XHR_LOCAL__")-3], nil
|
|
||||||
}
|
return nil
|
||||||
|
|
||||||
// использование токена
|
|
||||||
var (
|
|
||||||
cookie, token string
|
|
||||||
)
|
|
||||||
if cookie == "" || token == "" {
|
|
||||||
var e error
|
|
||||||
cookie, token, e = update()
|
|
||||||
if e != nil {
|
|
||||||
return "", e
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func puppy(data string) (string, error) {
|
||||||
var url strings.Builder
|
var url strings.Builder
|
||||||
url.WriteString("https://www.deviantart.com/_puppy/")
|
url.WriteString("https://www.deviantart.com/_puppy/")
|
||||||
url.WriteString(data)
|
url.WriteString(data)
|
||||||
|
Loading…
Reference in New Issue
Block a user