<commit_before>/*
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 (
	"flag"
	"io"
	"io/ioutil"
	"log"
	"net/http"
	"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(string(key))

	for _, i := range flag.Args() {
		id, err := strconv.Atoi(i)
		if err != nil {
			log.Printf("Bad number %s", i)
			continue
		}

		img, err := c.GetImage(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)
			}
		}

		fout, err := os.Create("/home/xena/pictures/derpi/" + img.FileName)
		if err != nil {
			panic(err)
		}
		defer fout.Close()<commit_msg>better file names<commit_after>/*
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 (
	"flag"
	"io"
	"io/ioutil"
	"log"
	"net/http"
	"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(string(key))

	for _, i := range flag.Args() {
		id, err := strconv.Atoi(i)
		if err != nil {
			log.Printf("Bad number %s", i)
			continue
		}

		img, err := c.GetImage(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)
			}
		}

		fout, err := os.Create("/home/xena/pictures/derpi/" + img.ID + " " + img.Tags + "." + img.OriginalFormat)
		if err != nil {
			panic(err)
		}
		defer fout.Close()
{'fraction_non_alphanumeric': 0.16577380952380952, 'fraction_numerical': 0.009523809523809525, 'mean_word_length': 2.9964328180737216, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4488719', 'n_tokens_mistral': 1441, 'n_tokens_neox': 1268, 'n_words': 357}