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

This commit is contained in:
lost+skunk 2024-06-27 14:52:33 +03:00
parent cec788554a
commit efa4b86a67
5 changed files with 75 additions and 53 deletions

16
.vscode/launch.json vendored Normal file
View File

@ -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
}
]
}

View File

@ -23,7 +23,7 @@ type Comments struct {
Desctiption string Desctiption string
Comment string Comment string
TextContent text TextContent Text
User struct { User struct {
Username string Username string

View File

@ -35,21 +35,21 @@ type Deviation struct {
Stats struct { Stats struct {
Favourites, Views, Downloads int Favourites, Views, Downloads int
} }
Media media Media Media
Extended struct { Extended struct {
Tags []struct { Tags []struct {
Name string Name string
} }
DescriptionText text DescriptionText Text
RelatedContent []struct { RelatedContent []struct {
Deviations []Deviation Deviations []Deviation
} }
} }
TextContent text TextContent Text
} }
// её выпердыши // её выпердыши
type media struct { type Media struct {
BaseUri string BaseUri string
Token []string Token []string
Types []struct { Types []struct {
@ -58,7 +58,7 @@ type media struct {
} }
} }
type text struct { type Text struct {
Excerpt string Excerpt string
Html struct { Html struct {
Markup, Type string Markup, Type string
@ -83,7 +83,7 @@ type Post struct {
} }
// преобразование урла в правильный // преобразование урла в правильный
func UrlFromMedia(m media) string { func UrlFromMedia(m Media) string {
var url strings.Builder var url strings.Builder
for _, t := range m.Types { for _, t := range m.Types {
if t.T == "fullview" { if t.T == "fullview" {

View File

@ -48,7 +48,6 @@ 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") req.Header.Set("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0.0")
// куки и UA-шник // куки и UA-шник
if other != nil {
for num, rng := range other { for num, rng := range other {
switch num { switch num {
case 1: case 1:
@ -57,7 +56,6 @@ func request(uri string, other ...string) reqrt {
req.Header.Set("Cookie", rng) req.Header.Set("Cookie", rng)
} }
} }
}
resp, e := cli.Do(req) resp, e := cli.Do(req)
err(e) err(e)
@ -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 */ /* 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=") url.WriteString("&type=gallery&order=most-recent&init=true&limit=50&q=")
} else { } else {
e = errors.New("Missing username (last argument)") e = errors.New("missing username (last argument)")
return return
} }
default: default:

View File

@ -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 { type GRuser struct {
ErrorDescription string ErrorDescription string
Owner struct { Owner struct {
@ -18,32 +50,10 @@ type GRuser struct {
Modules []struct { Modules []struct {
Name string Name string
ModuleData struct { ModuleData struct {
About struct { groups
Country, Website, WebsiteLabel, Gender, Tagline string users
DeviantFor int64
SocialLinks []struct {
Value string
}
TextContent text
Interests []struct {
Label, Value string
}
}
CoverDeviation struct {
Deviation Deviation `json:"coverDeviation"`
}
// группы // группы
GroupAbout struct {
Tagline string
CreatinDate time `json:"foundationTs"`
Description text
}
GroupAdmins struct {
Results []struct {
Username string
}
}
Folders struct { Folders struct {
Results []struct { Results []struct {
FolderId int FolderId int
@ -52,7 +62,6 @@ type GRuser struct {
} }
// галерея // галерея
ModuleData struct {
Folder struct { Folder struct {
Username string Username string
Pages int `json:"totalPageCount"` Pages int `json:"totalPageCount"`
@ -62,14 +71,13 @@ type GRuser struct {
} }
} }
} }
} Extra struct {
PageExtraData struct { Tag string `json:"gruserTagline"`
GruserTagline string
Stats struct { Stats struct {
Deviations, Watchers, Watching, Pageviews, CommentsMade, Favourites, Friends int Deviations, Watchers, Watching, Pageviews, CommentsMade, Favourites, Friends int
FeedComments int `json:"commentsReceivedProfile"` FeedComments int `json:"commentsReceivedProfile"`
} }
} } `json:"pageExtraData"`
} }
type Group struct { 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) ujson("dauserprofile/init/about?username="+s.Name, &g)
return return