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

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
Comment string
TextContent text
TextContent Text
User struct {
Username string

View File

@ -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" {

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")
// куки и UA-шник
if other != nil {
for num, rng := range other {
switch num {
case 1:
@ -57,7 +56,6 @@ func request(uri string, other ...string) reqrt {
req.Header.Set("Cookie", rng)
}
}
}
resp, e := cli.Do(req)
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 */
@ -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:

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 {
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,7 +62,6 @@ type GRuser struct {
}
// галерея
ModuleData struct {
Folder struct {
Username string
Pages int `json:"totalPageCount"`
@ -62,14 +71,13 @@ type GRuser struct {
}
}
}
}
PageExtraData struct {
GruserTagline string
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