aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlost+skunk <[email protected]>2024-06-27 14:52:33 +0300
committerlost+skunk <[email protected]>2024-06-27 14:52:33 +0300
commitefa4b86a67d67ce9ff1ff19391dbf73f13daece6 (patch)
tree44798c595a1e777b3cd4f58f7f60179fb79c9fc8
parentcec788554afe20b8c67357ede087b3c5c543be89 (diff)
downloaddevianter-efa4b86a67d67ce9ff1ff19391dbf73f13daece6.tar.gz
devianter-efa4b86a67d67ce9ff1ff19391dbf73f13daece6.tar.bz2
devianter-efa4b86a67d67ce9ff1ff19391dbf73f13daece6.zip
крымские наработки
-rw-r--r--.vscode/launch.json16
-rw-r--r--comments.go2
-rw-r--r--deviantion.go12
-rw-r--r--misc.go18
-rw-r--r--user-group.go80
5 files changed, 75 insertions, 53 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..fa75212
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,16 @@
+{
+ // Use IntelliSense to learn about possible attributes.
+ // Hover to view descriptions of existing attributes.
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "Launch Package",
+ "type": "go",
+ "request": "launch",
+ "mode": "debug",
+ "program": "${fileDirname}",
+ "showLog": true
+ }
+ ]
+} \ No newline at end of file
diff --git a/comments.go b/comments.go
index e8b58e2..47a0136 100644
--- a/comments.go
+++ b/comments.go
@@ -23,7 +23,7 @@ type Comments struct {
Desctiption string
Comment string
- TextContent text
+ TextContent Text
User struct {
Username string
diff --git a/deviantion.go b/deviantion.go
index 19405a4..e955b12 100644
--- a/deviantion.go
+++ b/deviantion.go
@@ -35,21 +35,21 @@ type Deviation struct {
Stats struct {
Favourites, Views, Downloads int
}
- Media media
+ Media Media
Extended struct {
Tags []struct {
Name string
}
- DescriptionText text
+ DescriptionText Text
RelatedContent []struct {
Deviations []Deviation
}
}
- TextContent text
+ TextContent Text
}
// её выпердыши
-type media struct {
+type Media struct {
BaseUri string
Token []string
Types []struct {
@@ -58,7 +58,7 @@ type media struct {
}
}
-type text struct {
+type Text struct {
Excerpt string
Html struct {
Markup, Type string
@@ -83,7 +83,7 @@ type Post struct {
}
// преобразование урла в правильный
-func UrlFromMedia(m media) string {
+func UrlFromMedia(m Media) string {
var url strings.Builder
for _, t := range m.Types {
if t.T == "fullview" {
diff --git a/misc.go b/misc.go
index 35251f3..6584479 100644
--- a/misc.go
+++ b/misc.go
@@ -48,14 +48,12 @@ func request(uri string, other ...string) reqrt {
req.Header.Set("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0.0")
// куки и UA-шник
- if other != nil {
- for num, rng := range other {
- switch num {
- case 1:
- req.Header.Set("User-Agent", rng)
- case 0:
- req.Header.Set("Cookie", rng)
- }
+ for num, rng := range other {
+ switch num {
+ case 1:
+ req.Header.Set("User-Agent", rng)
+ case 0:
+ req.Header.Set("Cookie", rng)
}
}
@@ -112,7 +110,7 @@ func AEmedia(name string, t rune) (string, error) {
}
}
- return "", errors.New("User not exists")
+ return "", errors.New("user not exists")
}
/* DAILY DEVIATIONS */
@@ -157,7 +155,7 @@ func SearchFunc(query string, page int, scope rune, user ...string) (ss Search,
}
url.WriteString("&type=gallery&order=most-recent&init=true&limit=50&q=")
} else {
- e = errors.New("Missing username (last argument)")
+ e = errors.New("missing username (last argument)")
return
}
default:
diff --git a/user-group.go b/user-group.go
index c9a1f2b..1247ffe 100644
--- a/user-group.go
+++ b/user-group.go
@@ -6,6 +6,38 @@ import (
)
// структура группы или пользователя
+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"`
+ }
+}
+
type GRuser struct {
ErrorDescription string
Owner struct {
@@ -18,32 +50,10 @@ type GRuser struct {
Modules []struct {
Name string
ModuleData struct {
- About struct {
- Country, Website, WebsiteLabel, Gender, Tagline string
- DeviantFor int64
- SocialLinks []struct {
- Value string
- }
- TextContent text
- Interests []struct {
- Label, Value string
- }
- }
- CoverDeviation struct {
- Deviation Deviation `json:"coverDeviation"`
- }
+ groups
+ users
// группы
- GroupAbout struct {
- Tagline string
- CreatinDate time `json:"foundationTs"`
- Description text
- }
- GroupAdmins struct {
- Results []struct {
- Username string
- }
- }
Folders struct {
Results []struct {
FolderId int
@@ -52,24 +62,22 @@ type GRuser struct {
}
// галерея
- ModuleData struct {
- Folder struct {
- Username string
- Pages int `json:"totalPageCount"`
- Deviations []Deviation
- } `json:"folderDeviations"`
- }
+ Folder struct {
+ Username string
+ Pages int `json:"totalPageCount"`
+ Deviations []Deviation
+ } `json:"folderDeviations"`
}
}
}
}
- PageExtraData struct {
- GruserTagline string
- Stats struct {
+ Extra struct {
+ Tag string `json:"gruserTagline"`
+ Stats struct {
Deviations, Watchers, Watching, Pageviews, CommentsMade, Favourites, Friends int
FeedComments int `json:"commentsReceivedProfile"`
}
- }
+ } `json:"pageExtraData"`
}
type Group struct {
@@ -78,7 +86,7 @@ type Group struct {
}
// подходит как группа, так и пользователь
-func (s Group) GroupFunc() (g Group) {
+func (s Group) GroupFunc() (g GRuser) {
ujson("dauserprofile/init/about?username="+s.Name, &g)
return