summaryrefslogtreecommitdiff
path: root/user-group.go
diff options
context:
space:
mode:
authorlost+skunk <[email protected]>2024-08-14 19:18:40 +0300
committerlost+skunk <[email protected]>2024-08-14 19:18:40 +0300
commit4487cdcbe9ed2ad4bc661c04600336505054177c (patch)
tree1bfba9d5bf27bb4b4a96d6c8a010c06eecbd0b4e /user-group.go
parent42ea2980f9be365c97b17d5273270fa1862ee9fc (diff)
downloaddevianter-4487cdcbe9ed2ad4bc661c04600336505054177c.tar.gz
devianter-4487cdcbe9ed2ad4bc661c04600336505054177c.tar.bz2
devianter-4487cdcbe9ed2ad4bc661c04600336505054177c.zip
user favs
Diffstat (limited to 'user-group.go')
-rw-r--r--user-group.go38
1 files changed, 32 insertions, 6 deletions
diff --git a/user-group.go b/user-group.go
index c6b53ee..f1f2af5 100644
--- a/user-group.go
+++ b/user-group.go
@@ -46,10 +46,11 @@ type Gallery struct {
Folders struct {
HasMore bool
Results []struct {
- FolderId int
- Size int
- Name string
- Thumb Deviation
+ Deviations int `json:"totalItemCount"`
+ FolderId int
+ Size int
+ Name string
+ Thumb Deviation
}
}
@@ -74,7 +75,7 @@ type Group struct {
}
// подходит как группа, так и пользователь
-func (s Group) GetGroup() (g GRuser, err error) {
+func (s Group) Get() (g GRuser, err error) {
if s.Name == "" {
return g, errors.New("missing Name field")
}
@@ -83,8 +84,33 @@ func (s Group) GetGroup() (g GRuser, err error) {
return
}
+func (s Group) Favourites(page int, all bool, folderid ...int) (g Group) {
+ var url strings.Builder
+
+ if fid := folderid[0]; fid > 0 || all {
+ url.WriteString("dashared/gallection/contents")
+ if all {
+ url.WriteString("?all_folder=true")
+ } else {
+ url.WriteString("?folderid=")
+ url.WriteString(strconv.Itoa(fid))
+ }
+ url.WriteString("&type=collection&")
+ } else {
+ url.WriteString("dauserprofile/init/favourites?deviations_")
+ }
+
+ url.WriteString("limit=50&username=")
+ url.WriteString(s.Name)
+ url.WriteString("&with_subfolders=true&offset=")
+ url.WriteString(strconv.Itoa(page * 50))
+
+ ujson(url.String(), &g.Content)
+ return
+}
+
// гарелея пользователя или группы
-func (s Group) GetGallery(page int, folderid ...int) (g Group, err error) {
+func (s Group) Gallery(page int, folderid ...int) (g Group, err error) {
if s.Name == "" {
return g, errors.New("missing Name field")
}