devianter/user-group.go

107 lines
2.2 KiB
Go
Raw Normal View History

package devianter
import (
"strconv"
"strings"
)
// структура группы или пользователя
2024-06-27 11:52:33 +00:00
type groups struct {
GroupAbout struct {
FoundatedAt time `json:"foundationTs"`
Description Text
}
GroupAdmins struct {
Results []struct {
Username string
}
}
}
type About struct {
Country, Website, WebsiteLabel, Gender string
RegDate int64 `json:"deviantFor"`
Description Text `json:"textContent"`
SocialLinks []struct {
Value string
}
Interests []struct {
Label, Value string
}
}
type users struct {
About About
CoverDeviation struct {
Deviation Deviation `json:"coverDeviation"`
}
}
2024-06-13 21:05:21 +00:00
type GRuser struct {
ErrorDescription string
Owner struct {
Group bool `json:"isGroup"`
Username string
}
Gruser struct {
ID int `json:"gruserId"`
Page struct {
Modules []struct {
Name string
ModuleData struct {
2024-06-27 11:52:33 +00:00
groups
users
// группы
Folders struct {
Results []struct {
FolderId int
Name string
}
}
// галерея
2024-06-27 11:52:33 +00:00
Folder struct {
Username string
Pages int `json:"totalPageCount"`
Deviations []Deviation
} `json:"folderDeviations"`
}
}
}
}
2024-06-27 11:52:33 +00:00
Extra struct {
Tag string `json:"gruserTagline"`
Stats struct {
Deviations, Watchers, Watching, Pageviews, CommentsMade, Favourites, Friends int
FeedComments int `json:"commentsReceivedProfile"`
}
2024-06-27 11:52:33 +00:00
} `json:"pageExtraData"`
}
2024-06-13 21:05:21 +00:00
type Group struct {
Name string // обязательно заполнить
Content GRuser
}
// подходит как группа, так и пользователь
2024-06-27 11:52:33 +00:00
func (s Group) GroupFunc() (g GRuser) {
2024-06-13 21:05:21 +00:00
ujson("dauserprofile/init/about?username="+s.Name, &g)
return
}
// гарелея пользователя или группы
2024-06-13 21:05:21 +00:00
func (s Group) Gallery(page int) (g Group) {
var url strings.Builder
url.WriteString("dauserprofile/init/gallery?username=")
2024-06-13 21:05:21 +00:00
url.WriteString(s.Name)
url.WriteString("&page=")
url.WriteString(strconv.Itoa(page))
url.WriteString("&deviations_limit=50&with_subfolders=false")
ujson(url.String(), &g)
return
}