diff --git a/modules/e621/main.go b/modules/e621/main.go index 778ff6c..e2a9dbc 100644 --- a/modules/e621/main.go +++ b/modules/e621/main.go @@ -122,24 +122,24 @@ func Query(uname string, api_key string, tags []string, j_max Jobs, tout time.Du res_chan := make(chan result) var r_arr []result - q := &http.Request{ - URL: &url.URL{ - Scheme: "https", - Host: "e621.net", - Path: "/posts.json", - }, - Header: make(http.Header), - } - q.Header.Set("user-agent", "goboru/1.0 (caskd@redxen.eu, https://git.redxen.eu/caskd/goboru)") - uq := q.URL.Query() - uq.Set("tags", strings.Join(tags, " ")) - if uname != "" && api_key != "" { - uq.Set("login", uname) - uq.Set("api_key", api_key) - } - q.URL.RawQuery = uq.Encode() - for pid, rpid, ppid := Page(0), Page(0), Page(0); ; { + q := &http.Request{ + URL: &url.URL{ + Scheme: "https", + Host: "e621.net", + Path: "/posts.json", + }, + Header: make(http.Header), + } + q.Header.Set("user-agent", "goboru/1.0 (caskd@redxen.eu, https://git.redxen.eu/caskd/goboru)") + uq := q.URL.Query() + uq.Set("tags", strings.Join(tags, " ")) + if uname != "" && api_key != "" { + uq.Set("login", uname) + uq.Set("api_key", api_key) + } + q.URL.RawQuery = uq.Encode() + go run_job(q, tout, pid, res_chan) pid++ diff --git a/modules/gelbooru/main.go b/modules/gelbooru/main.go index 8dce836..8e9c360 100644 --- a/modules/gelbooru/main.go +++ b/modules/gelbooru/main.go @@ -82,22 +82,22 @@ func Query(tags Tags, j_max Jobs) (mr []Media, err error) { res_chan := make(chan result) var r_arr []result - q := &http.Request{ - URL: &url.URL{ - Scheme: "https", - Host: "gelbooru.com", - Path: "/index.php", - }, - } - qu := q.URL.Query() - qu.Set("page", "dapi") - qu.Set("s", "post") - qu.Set("q", "index") - qu.Set("json", "1") - qu.Set("tags", strings.Join(tags, " ")) - q.URL.RawQuery = qu.Encode() - for pid, rpid, ppid := uint(0), uint(0), uint(0); ; { + q := &http.Request{ + URL: &url.URL{ + Scheme: "https", + Host: "gelbooru.com", + Path: "/index.php", + }, + } + qu := q.URL.Query() + qu.Set("page", "dapi") + qu.Set("s", "post") + qu.Set("q", "index") + qu.Set("json", "1") + qu.Set("tags", strings.Join(tags, " ")) + q.URL.RawQuery = qu.Encode() + if pid <= 200 { // API only allows to fetch up to 200 pages per query go run_job(q, pid, res_chan) pid++