Danbooru

Batch download a tag set

Posted under General

AndarielHalo said:
I don't mean to bump it, but this is the best and most reliable function for me to use. I tried the Strawberry Perl, but it wouldn't function; the bat would close as soon as I opened it, without doing anything.

Fine, here's a v2.0. Won't work for flash, but whatever.

javascript:links = document.evaluate('//img',document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); document.body.innerHTML = ""; newBody = ""; function makeLink(link,ext) { return '<a href="' + link.replace(/jpg$/i,ext) + '">img</a>'; }; for (var i = 0; i < links.snapshotLength; i++) {thisLink = links.snapshotItem(i).src.replace(/preview\//,'');if (!/\/data\//.test(thisLink)) continue; newBody = newBody + makeLink(thisLink,'jpg') + makeLink(thisLink,'png') + makeLink(thisLink,'gif') + '
'; if (i%20 == 0) {document.body.innerHTML += newBody; newBody = "";} }; document.body.innerHTML += newBody; alert('done');

Updated

Granola said:
Sometimes it doesn't work (something not being able to use a string as a hash ref).

Yeah, I've been using the program with good success on Sagubooru and Moe Imouto, but I get that error a lot when using it on Danbooru. Sometimes, it gets the error immediately, other times it gets to a certain point before getting the error.

"Can't use string (Couln't GET http://danbooru.donm") as a HASH ref while "strict refs" in use at booru.pl line 83."

That's the full error. I know nothing about writing code so it's pretty meaningless to me. Also, someone mentioned Gelbooru earlier, but I don't think the program works with Gelbooru right now. At least, it never has for me. http://gelbooru.com/index.php?page=forum&s=view&id=81 may be relevant.

Zoom said:
..."Can't use string (Couln't GET http://danbooru.donm") as a HASH ref while "strict refs" in use at booru.pl line 83."

This error is most likely caused by the unregistered user restriction page (Serving to many files, please register for a basic account, etc) which was an addition that came after the last script update.

HatsuneMiku said:
This error is most likely caused by the unregistered user restriction page (Serving to many files, please register for a basic account, etc) which was an addition that came after the last script update.

Untrue, this happens even while I am logged in.

HatsuneMiku said:
That's due to the nature of the script, as I do not believe it relies on cookies.

It strikes me as odd that it wouldn't use the in-URL username and passhash method at least, like so:

http://danbooru.donmai.us/post/index.json?tags=tags&page=page&login=username&password_hash=password_hash

But I've never looked at the script, so I don't know what it does.

RaisingK said:
It strikes me as odd that it wouldn't use the in-URL username and passhash method at least, like so:

http://danbooru.donmai.us/post/index.json?tags=tags&page=page&login=username&password_hash=password_hash

But I've never looked at the script, so I don't know what it does.

Found a part in dan.pm about this login stuff.

Unsure what to make of it.

Okay, here's an update. I appear to have "fixed" this (probably not) by deleting the line "use strict" in dan.pm

You can probably get this to work with the other boorus by deleting the "use strict" line in the corresponding .pm file. I have a bad feeling that I've broken something in it but it seems to work and that's what's important.

Still like to find someone who had made this thing in the first place...

http://www.mediafire.com/?km4dzzztm5z version 1.1
requires perl, download strawberry perl.

edit: okay maybe not...

Modified booru.pl so that it has an option to make use of the login subroutine found in the booru package. Pretty much a copy paste job taking parts from the booru-upload.pl script.

All credit for the script goes to AoRF seeing as how he was the one who originally wrote the thing and all I did was re-use some code from the other scripts he wrote.

Though the chances of things breaking are relatively low since there are only minor modifications made and none to the supporting modules, there is still the possibility that something might not work for whatever reason.

There is no need to use the SHA1 hash of the password since this does not insert it into the url.

The syntax for use is pretty much the same as with the original edition, what you do is (using the path option as an example):

perl boorupw.pl danbooru <query here> --path="directory" -u=username -w=password

http://www.mediafire.com/?yned2mwyyzz

Updated

Granola said:
1. Navigate into the folder containing the tools using command prompt. (cd C:\booru is my location)
2. The syntax you will use is "perl booru.pl -u=USERNAME -p=PASSWORD [booru location you will be using, in this case danbooru] [tag, can be more than one]"

Take a look at the example enclosed. the line "perl booru.pl danbooru hakurei_reimu -f={md5}" will download all images with the hakurei_reimu tag and name them with their md5 hashes. There are more modifiers you can add to make your life easier.

-f= (filename template, I just leave these to {md5})
-l=NUMBER (limits downloads to a certain number)
-s=NUMBER (downloads from a post # forward)
-r=NUMBER (Downloads based on rating. 1=safe 2=questionable 3=explicit)
-p= (sets path to save the files in instead of the current directory. a real lifesaver when you start to put this stuff in batch files. Remember to use quotes if you have any spaces in your path)

example:
perl booru.pl danbooru ibuki_fuuko -r=3 -f=${md5} -p="C:\Pictures\Fuuko"

Will download all ibkui_fuuko tags that are rated explicit from danbooru and name them with their md5 hashes and place them in the C:\Pictures\Fuuko directory.

Yeah you have to use command prompt. I don't know of any other way besides pictures to explain it.

Use .bat files to make your life easier and automate this whole thing.

lovely! u kno, i think itd be nice to have a team of programers turning that script into nicely interfaced program :).

btw Granola, how do i make the bat file?
or rather, can you upload it?
i have no idea how to make one :S:S:S:S

Updated

takarosie said:
lovely! u kno, i think itd be nice to have a team of programers turning that script into nicely interfaced program :).

btw Granola, how do i make the bat file?
or rather, can you upload it?
i have no idea how to make one :S:S:S:S

Make a text document.

Put your line of code into it, your
perl booru.pl danbooru ibuki_fuuko -r=3 -f=${md5} -p="C:\Pictures\Fuuko"
or what have you. (DONT FORGET YOUR USERNAME/PASSWORD THING)

Save this text document.

Change the file extension into .bat

Double click dat bat.

Note that you can put multiple lines into the .bat file; this way you can automate all of your downloads.

1 2 3 4 5 6 9