diff --git a/cmd/admin/db-massdelete/.gitignore b/cmd/admin/db-massdelete/.gitignore deleted file mode 100644 index 5809336..0000000 --- a/cmd/admin/db-massdelete/.gitignore +++ /dev/null @@ -1 +0,0 @@ -db-massdelete diff --git a/cmd/admin/db-massdelete/README.md b/cmd/admin/db-massdelete/README.md deleted file mode 100644 index da7f570..0000000 --- a/cmd/admin/db-massdelete/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# db-massdelete --- -Command db-massdelete handles mass deletion of derpibooru images. - -Please use this sparingly. - -Usage: - - Usage of ./db-massdelete: - -keyFile="/home/xena/.local/share/within/db.cadance.key": file with the derpibooru key to use - -reason="": reason to use when deleting images - -Then give it the image ID's you want to delete. - - ./db-massdelete -reason "OP is a duck" 123 325 1561 136324 diff --git a/cmd/admin/db-massdelete/main.go b/cmd/admin/db-massdelete/main.go deleted file mode 100644 index 30c574c..0000000 --- a/cmd/admin/db-massdelete/main.go +++ /dev/null @@ -1,120 +0,0 @@ -/* -Command db-massdelete handles mass deletion of derpibooru images. - -Please use this sparingly. - -Usage: - - Usage of ./db-massdelete: - -keyFile="/home/xena/.local/share/within/db.cadance.key": file with the derpibooru key to use - -reason="": reason to use when deleting images - -Then give it the image ID's you want to delete. - - ./db-massdelete -reason "OP is a duck" 123 325 1561 136324 -*/ -package main - -import ( - "context" - "flag" - "io" - "io/ioutil" - "log" - "net/http" - "net/url" - "os" - "strconv" - "strings" - - "github.com/Xe/derpigo" -) - -var ( - keyFile = flag.String("keyFile", "/home/xena/.local/share/within/db.cadance.key", "file with the derpibooru key to use") - reason = flag.String("reason", "", "reason to use when deleting images") - needTag = flag.String("needtag", "", "optional tag an image must have to be deleted") -) - -func main() { - flag.Parse() - - if *reason == "" { - log.Fatal("Need a reason") - } - - key, err := ioutil.ReadFile(*keyFile) - if err != nil { - log.Fatal(err) - } - - c := derpigo.New(derpigo.WithAPIKey(string(key))) - - for _, i := range flag.Args() { - id, err := strconv.Atoi(i) - if err != nil { - if strings.HasPrefix(i, "http") { - url, err := url.Parse(i) - if err != nil { - log.Printf("error reading %s: %#v", i, err) - continue - } - - realid, err := strconv.Atoi(url.Path[1:]) - if err != nil { - log.Printf("I don't understand %s", url.Path) - continue - } - - id = realid - } - } - - img, _, err := c.GetImage(context.Background(), id) - if err != nil { - log.Printf("couldn't fetch info on image %d: %v", id, err) - } - - if *needTag != "" { - ok := false - - for _, tag := range strings.Split(img.Tags, ", ") { - if tag == *needTag { - ok = true - } - } - - if !ok && *needTag != "" { - log.Printf("Can't delete %d, doesn't have the tag %s", id, *needTag) - continue - } - } - - tags := strings.Split(img.Tags, ", ") - if len(tags) > 10 { - tags = tags[0:11] - } - - fout, err := os.Create("/home/xena/pictures/derpi/" + img.ID + " " + strings.Join(tags, ", ") + "." + img.OriginalFormat) - if err != nil { - panic(err) - } - defer fout.Close() - - resp, err := http.Get("https:" + img.Image) - if err != nil { - log.Printf("could not download image: %v", err) - continue - } - defer resp.Body.Close() - - io.Copy(fout, resp.Body) - - err = c.DeleteImage(context.Background(), i, *reason) - if err != nil { - panic(err) - } - - log.Printf("Deleted %s because %s", i, *reason) - } -} diff --git a/cmd/db-archive/.gitignore b/cmd/db-archive/.gitignore deleted file mode 100644 index 1972833..0000000 --- a/cmd/db-archive/.gitignore +++ /dev/null @@ -1 +0,0 @@ -db-archive \ No newline at end of file diff --git a/cmd/db-archive/doc.go b/cmd/db-archive/doc.go deleted file mode 100644 index 9eac5ef..0000000 --- a/cmd/db-archive/doc.go +++ /dev/null @@ -1,6 +0,0 @@ -/* -Command db-archive downloads and serves images from Derpibooru, fetched via derpigo and stored in boltdb. - -Optionally this will also have a worker that connects to irc.ponychat.net and joins #derpibooru-livefeed to automatically download and add new images. -*/ -package main diff --git a/cmd/db-archive/main.go b/cmd/db-archive/main.go deleted file mode 100644 index e8bbf2f..0000000 --- a/cmd/db-archive/main.go +++ /dev/null @@ -1,86 +0,0 @@ -package main - -import ( - "context" - "flag" - "io" - "io/ioutil" - "log" - "net/http" - "net/url" - "os" - "strconv" - "strings" - - "github.com/Xe/derpigo" -) - -var ( - keyFile = flag.String("keyfile", os.Getenv("HOME")+"/.local/share/within/db.cadance.key", "file with the derpibooru key to use") - outDir = flag.String("outdir", ".", "directory to download images to") -) - -func main() { - flag.Parse() - - key, err := ioutil.ReadFile(*keyFile) - if err != nil { - log.Fatal(err) - } - - ctx := context.Background() - ctx, cancel := context.WithCancel(ctx) - defer cancel() - - c := derpigo.New(derpigo.WithAPIKey(string(key))) - - for _, i := range flag.Args() { - id, err := strconv.Atoi(i) - if err != nil { - if strings.HasPrefix(i, "http") { - url, err := url.Parse(i) - if err != nil { - log.Printf("error reading %s: %#v", i, err) - continue - } - - realid, err := strconv.Atoi(url.Path[1:]) - if err != nil { - log.Printf("I don't understand %s", url.Path) - continue - } - - id = realid - } - } - - img, _, err := c.GetImage(ctx, id) - if err != nil { - log.Printf("couldn't fetch info on image %d: %v", id, err) - } - - tags := strings.Split(img.Tags, ", ") - if len(tags) > 10 { - tags = tags[0:11] - } - - foutpath := *outDir + img.ID + " " + strings.Join(tags, ", ") + "." + img.OriginalFormat - - fout, err := os.Create(foutpath) - if err != nil { - panic(err) - } - defer fout.Close() - - resp, err := http.Get("https:" + img.Image) - if err != nil { - log.Printf("could not download image: %v", err) - continue - } - defer resp.Body.Close() - - io.Copy(fout, resp.Body) - - log.Printf("downloaded %v to %v", i, foutpath) - } -} diff --git a/go.mod b/go.mod index 357d015..405369a 100644 --- a/go.mod +++ b/go.mod @@ -1 +1 @@ -module within.website/derpigo +module within.website/derpigo/v2