krz/devianter

A DeviantArt guest API library for Go.

clone: git clone https://gitbay.org/krz/devianter.git

v0.1.0: user-group.go · raw

 1package devianter
 2
 3import (
 4	"strconv"
 5	"strings"
 6)
 7
 8// структура группы или пользователя
 9type Group struct {
10	ErrorDescription string
11	Owner            struct {
12		Group    bool `json:"isGroup"`
13		Username string
14	}
15	Gruser struct {
16		ID   int `json:"gruserId"`
17		Page struct {
18			Modules []struct {
19				Name       string
20				ModuleData struct {
21					About struct {
22						Country, Website, WebsiteLabel, Gender, Tagline string
23						DeviantFor                                      int64
24						SocialLinks                                     []struct {
25							Value string
26						}
27						TextContent text
28						Interests   []struct {
29							Label, Value string
30						}
31					}
32					CoverDeviation struct {
33						Deviation deviantion `json:"coverDeviation"`
34					}
35
36					// группы
37					GroupAbout struct {
38						Tagline     string
39						CreatinDate time `json:"foundationTs"`
40						Description text
41					}
42					GroupAdmins struct {
43						Results []struct {
44							Username string
45						}
46					}
47					Folders struct {
48						Results []struct {
49							FolderId int
50							Name     string
51						}
52					}
53
54					// галерея
55					ModuleData struct {
56						Folder struct {
57							Username   string
58							Pages      int `json:"totalPageCount"`
59							Deviations []deviantion
60						} `json:"folderDeviations"`
61					}
62				}
63			}
64		}
65	}
66	PageExtraData struct {
67		GruserTagline string
68		Stats         struct {
69			Deviations, Watchers, Watching, Pageviews, CommentsMade, Favourites, Friends int
70			FeedComments                                                                 int `json:"commentsReceivedProfile"`
71		}
72	}
73}
74
75func UGroup(name string) (g Group) {
76	ujson("dauserprofile/init/about?username="+name, &g)
77
78	return
79}
80
81// гарелея пользователя или группы
82func Gallery(name string, page int) (g Group) {
83	var url strings.Builder
84	url.WriteString("dauserprofile/init/gallery?username=")
85	url.WriteString(name)
86	url.WriteString("&page=")
87	url.WriteString(strconv.Itoa(page))
88	url.WriteString("&deviations_limit=50&with_subfolders=false")
89
90	ujson(url.String(), &g)
91	return
92}