diff options
| author | lost+skunk <[email protected]> | 2024-06-30 14:39:11 +0300 |
|---|---|---|
| committer | lost+skunk <[email protected]> | 2024-06-30 14:39:11 +0300 |
| commit | 949bef2c5d5ee53a5d6158e16921c698f8a6e266 (patch) | |
| tree | 5d6fb17999bfd41ed98e6caa1453a3874afe9867 /misc.go | |
| parent | efa4b86a67d67ce9ff1ff19391dbf73f13daece6 (diff) | |
| download | devianter-949bef2c5d5ee53a5d6158e16921c698f8a6e266.tar.gz devianter-949bef2c5d5ee53a5d6158e16921c698f8a6e266.tar.bz2 devianter-949bef2c5d5ee53a5d6158e16921c698f8a6e266.zip | |
по мелочи
Diffstat (limited to 'misc.go')
| -rw-r--r-- | misc.go | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -7,6 +7,7 @@ import ( "log" "math" "net/http" + u "net/url" "strconv" "strings" ) @@ -131,10 +132,11 @@ func DailyDeviationsFunc(page int) (dd DailyDeviations) { /* SEARCH */ type Search struct { - Total int `json:"estTotal"` - Pages int // only for 'a' and 'g' scope. - HasMore bool - Results []Deviation `json:"deviations,results"` + Total int `json:"estTotal"` + Pages int // only for 'a' and 'g' scope. + HasMore bool + Results []Deviation `json:"deviations"` + ResultsGalleryTemp []Deviation `json:"results"` } func SearchFunc(query string, page int, scope rune, user ...string) (ss Search, e error) { @@ -162,7 +164,7 @@ func SearchFunc(query string, page int, scope rune, user ...string) (ss Search, log.Fatalln("Invalid type.\n- 'a' -- all;\n- 't' -- tag;\n- 'g' - gallery.") } - url.WriteString(query) + url.WriteString(u.QueryEscape(query)) if scope != 'g' { // если область поиска не равна поиску по группам, то активируется этот код url.WriteString("&page=") } else { // иначе вместо страницы будет оффсет и страница умножится на 50 @@ -173,6 +175,10 @@ func SearchFunc(query string, page int, scope rune, user ...string) (ss Search, ujson(url.String(), &ss) + if scope == 'g' { + ss.Results = ss.ResultsGalleryTemp + } + // расчёт, сколько всего страниц по запросу. без токена 417 страниц - максимум totalfloat := int(math.Round(float64(ss.Total / 25))) for x := 0; x < totalfloat; x++ { |
