diff options
| author | lost+skunk <[email protected]> | 2024-07-30 01:20:00 +0300 |
|---|---|---|
| committer | lost+skunk <[email protected]> | 2024-07-30 01:20:00 +0300 |
| commit | 42ea2980f9be365c97b17d5273270fa1862ee9fc (patch) | |
| tree | 6a8cf69711a8065113b130678a2e6b57411f1937 /user-group.go | |
| parent | 4d166ad5f98377685a9dd47a0aaed547e67d79ce (diff) | |
| download | devianter-0.2.5.tar.gz devianter-0.2.5.tar.bz2 devianter-0.2.5.zip | |
Парсер медии с кастомным разрешениемv0.2.5
Diffstat (limited to 'user-group.go')
| -rw-r--r-- | user-group.go | 78 |
1 files changed, 43 insertions, 35 deletions
diff --git a/user-group.go b/user-group.go index 1592568..c6b53ee 100644 --- a/user-group.go +++ b/user-group.go @@ -1,44 +1,12 @@ package devianter import ( + "errors" "strconv" "strings" ) // структура группы или пользователя -type GroupAbout struct { - FoundatedAt time `json:"foundationTs"` - Description Text -} -type GroupAdmins struct { - Results []struct { - TypeId int - User 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"` - } -} - type GRuser struct { ErrorDescription string Owner struct { @@ -106,14 +74,21 @@ type Group struct { } // подходит как группа, так и пользователь -func (s Group) GroupFunc() (g GRuser) { +func (s Group) GetGroup() (g GRuser, err error) { + if s.Name == "" { + return g, errors.New("missing Name field") + } ujson("dauserprofile/init/about?username="+s.Name, &g) return } // гарелея пользователя или группы -func (s Group) Gallery(page int, folderid ...int) (g Group) { +func (s Group) GetGallery(page int, folderid ...int) (g Group, err error) { + if s.Name == "" { + return g, errors.New("missing Name field") + } + var url strings.Builder if folderid[0] > 0 { page-- @@ -137,3 +112,36 @@ func (s Group) Gallery(page int, folderid ...int) (g Group) { ujson(url.String(), &g.Content) return } + +type GroupAbout struct { + FoundatedAt timeStamp `json:"foundationTs"` + Description Text +} +type GroupAdmins struct { + Results []struct { + TypeId int + User 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"` + } +} |
