Commit efa4b86a67

efa4b86a67d67ce9ff1ff19391dbf73f13daece6

parent: cec788554a

Unsigned

lost+skunk <skunky@ebloid.ru> · 2024-06-27 11:52 UTC

крымские наработки

Layout: unified · split

.vscode/launch.json added +16
@@ -0,0 +1,16 @@
1{
2 // Use IntelliSense to learn about possible attributes.
3 // Hover to view descriptions of existing attributes.
4 // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 "version": "0.2.0",
6 "configurations": [
7 {
8 "name": "Launch Package",
9 "type": "go",
10 "request": "launch",
11 "mode": "debug",
12 "program": "${fileDirname}",
13 "showLog": true
14 }
15 ]
16}\ No newline at end of file
comments.go +1 −1
@@ -23,7 +23,7 @@ type Comments struct {
23 Desctiption string 23 Desctiption string
24 Comment string 24 Comment string
25 25
26 TextContent text 26 TextContent Text
27 27
28 User struct { 28 User struct {
29 Username string 29 Username string
deviantion.go +6 −6
@@ -35,21 +35,21 @@ type Deviation struct {
35 Stats struct { 35 Stats struct {
36 Favourites, Views, Downloads int 36 Favourites, Views, Downloads int
37 } 37 }
38 Media media 38 Media Media
39 Extended struct { 39 Extended struct {
40 Tags []struct { 40 Tags []struct {
41 Name string 41 Name string
42 } 42 }
43 DescriptionText text 43 DescriptionText Text
44 RelatedContent []struct { 44 RelatedContent []struct {
45 Deviations []Deviation 45 Deviations []Deviation
46 } 46 }
47 } 47 }
48 TextContent text 48 TextContent Text
49} 49}
50 50
51// её выпердыши 51// её выпердыши
52type media struct { 52type Media struct {
53 BaseUri string 53 BaseUri string
54 Token []string 54 Token []string
55 Types []struct { 55 Types []struct {
@@ -58,7 +58,7 @@ type media struct {
58 } 58 }
59} 59}
60 60
61type text struct { 61type Text struct {
62 Excerpt string 62 Excerpt string
63 Html struct { 63 Html struct {
64 Markup, Type string 64 Markup, Type string
@@ -83,7 +83,7 @@ type Post struct {
83} 83}
84 84
85// преобразование урла в правильный 85// преобразование урла в правильный
86func UrlFromMedia(m media) string { 86func UrlFromMedia(m Media) string {
87 var url strings.Builder 87 var url strings.Builder
88 for _, t := range m.Types { 88 for _, t := range m.Types {
89 if t.T == "fullview" { 89 if t.T == "fullview" {
misc.go +8 −10
@@ -48,14 +48,12 @@ func request(uri string, other ...string) reqrt {
48 req.Header.Set("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0.0") 48 req.Header.Set("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0.0")
49 49
50 // куки и UA-шник 50 // куки и UA-шник
51 if other != nil { 51 for num, rng := range other {
52 for num, rng := range other { 52 switch num {
53 switch num { 53 case 1:
54 case 1: 54 req.Header.Set("User-Agent", rng)
55 req.Header.Set("User-Agent", rng) 55 case 0:
56 case 0: 56 req.Header.Set("Cookie", rng)
57 req.Header.Set("Cookie", rng)
58 }
59 } 57 }
60 } 58 }
61 59
@@ -112,7 +110,7 @@ func AEmedia(name string, t rune) (string, error) {
112 } 110 }
113 } 111 }
114 112
115 return "", errors.New("User not exists") 113 return "", errors.New("user not exists")
116} 114}
117 115
118/* DAILY DEVIATIONS */ 116/* DAILY DEVIATIONS */
@@ -157,7 +155,7 @@ func SearchFunc(query string, page int, scope rune, user ...string) (ss Search,
157 } 155 }
158 url.WriteString("&type=gallery&order=most-recent&init=true&limit=50&q=") 156 url.WriteString("&type=gallery&order=most-recent&init=true&limit=50&q=")
159 } else { 157 } else {
160 e = errors.New("Missing username (last argument)") 158 e = errors.New("missing username (last argument)")
161 return 159 return
162 } 160 }
163 default: 161 default:
user-group.go +44 −36
@@ -6,6 +6,38 @@ import (
6) 6)
7 7
8// структура группы или пользователя 8// структура группы или пользователя
9type groups struct {
10 GroupAbout struct {
11 FoundatedAt time `json:"foundationTs"`
12 Description Text
13 }
14 GroupAdmins struct {
15 Results []struct {
16 Username string
17 }
18 }
19}
20
21type About struct {
22 Country, Website, WebsiteLabel, Gender string
23 RegDate int64 `json:"deviantFor"`
24 Description Text `json:"textContent"`
25
26 SocialLinks []struct {
27 Value string
28 }
29 Interests []struct {
30 Label, Value string
31 }
32}
33
34type users struct {
35 About About
36 CoverDeviation struct {
37 Deviation Deviation `json:"coverDeviation"`
38 }
39}
40
9type GRuser struct { 41type GRuser struct {
10 ErrorDescription string 42 ErrorDescription string
11 Owner struct { 43 Owner struct {
@@ -18,32 +50,10 @@ type GRuser struct {
18 Modules []struct { 50 Modules []struct {
19 Name string 51 Name string
20 ModuleData struct { 52 ModuleData struct {
21 About struct { 53 groups
22 Country, Website, WebsiteLabel, Gender, Tagline string 54 users
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 Deviation `json:"coverDeviation"`
34 }
35 55
36 // группы 56 // группы
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 { 57 Folders struct {
48 Results []struct { 58 Results []struct {
49 FolderId int 59 FolderId int
@@ -52,24 +62,22 @@ type GRuser struct {
52 } 62 }
53 63
54 // галерея 64 // галерея
55 ModuleData struct { 65 Folder struct {
56 Folder struct { 66 Username string
57 Username string 67 Pages int `json:"totalPageCount"`
58 Pages int `json:"totalPageCount"` 68 Deviations []Deviation
59 Deviations []Deviation 69 } `json:"folderDeviations"`
60 } `json:"folderDeviations"`
61 }
62 } 70 }
63 } 71 }
64 } 72 }
65 } 73 }
66 PageExtraData struct { 74 Extra struct {
67 GruserTagline string 75 Tag string `json:"gruserTagline"`
68 Stats struct { 76 Stats struct {
69 Deviations, Watchers, Watching, Pageviews, CommentsMade, Favourites, Friends int 77 Deviations, Watchers, Watching, Pageviews, CommentsMade, Favourites, Friends int
70 FeedComments int `json:"commentsReceivedProfile"` 78 FeedComments int `json:"commentsReceivedProfile"`
71 } 79 }
72 } 80 } `json:"pageExtraData"`
73} 81}
74 82
75type Group struct { 83type Group struct {
@@ -78,7 +86,7 @@ type Group struct {
78} 86}
79 87
80// подходит как группа, так и пользователь 88// подходит как группа, так и пользователь
81func (s Group) GroupFunc() (g Group) { 89func (s Group) GroupFunc() (g GRuser) {
82 ujson("dauserprofile/init/about?username="+s.Name, &g) 90 ujson("dauserprofile/init/about?username="+s.Name, &g)
83 91
84 return 92 return