There is a nice command line one involving perl that you can automate.
Here's a roundabout way:
- Get the Greasemonkey firefox extension, install the Endless Pages script.
- Run the query, and put something on the Page Down key until you've loaded all of the results.
- Dump this in the address bar and hit enter: javascript: var imageLink = document.getElementsByTagName("a"); for (i = 0; i < imageLink.length; i++) if (/\/post\/show\//.test(imageLink[i].href)) imageLink[i].href = imageLink[i].firstChild.src.replace(/preview\//,''); alert('done');
- Use the DownThemAll extension to download all of the images linked on the page (thumbs now all point directly to the image thanks to the above).
qqeor said:
But it seems to be broken with the current version of Danbooru...
Change the address on line 82 and it works just fine, actually.
This script could use some improvement, but it's a decent starting point at least.
If the mods say its okay, I can put a mediafire of the program I've seen work extremely well.
It's okay.
I'm not exactly a programmer so if I give a direction that doesn't really make sense forgive me. I did not write this and I don't really know who did, but whoever they are they're pretty smart.
First, you must get perl. I downloaded Strawberry Perl, it works pretty well.
Tools you will need to unzip into one folder. http://www.mediafire.com/?nwui2mqj2mk
I make these into .bat extensions so that I can download many tags automatically, but you can use cmd.exe as well.
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 [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)
-u=username -w=password = These should be put in to avoid the error of "couldn't get at line" xxx or whatever.
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.
There is some documentation included with this, although its not very user friendly. I don't know everything about this program, but if you want to ask me questions you can PM me.
My way seems simpler after all. ^^ Though maybe that perl code has more flexibility with all those parameters.
I like it because you can automate it to download an entire batch of tags.
I have like 70 folders they all need to go into, and i don't want to run a program 70 times.
I've used both, and while my explanation seems complicated it is really very simple once you put a few minutes into it. Using downthemall doesnt put them in directories and its hard to update.
Ahh, see in this case neither is greater or less: I can do the additional scripting on the fly as-needed with a one-liner in Bash. I feel sort of bad for Windows not having a proper shell.
Thanks for the help, guys!
DschingisKhan said:
I feel sort of bad for Windows not having a proper shell.
Powershell?
Or cygwin, if you're so inclined.
RaisingK said:
Here's a roundabout way:
- Get the Greasemonkey firefox extension, install the Endless Pages script.
- Run the query, and put something on the Page Down key until you've loaded all of the results.
- Dump this in the address bar and hit enter: javascript: var imageLink = document.getElementsByTagName("a"); for (i = 0; i < imageLink.length; i++) if (/\/post\/show\//.test(imageLink[i].href)) imageLink[i].href = imageLink[i].firstChild.src.replace(/preview\//,''); alert('done');
- Use the DownThemAll extension to download all of the images linked on the page (thumbs now all point directly to the image thanks to the above).
I just wanted to say that this method only works with files that have a .jpg extension. If an image is in .png format or anything else, it will show up as 404 not found because in the direct image link, the real extension is replaced with .jpg
Or maybe I'm just doing something wrong.
Ah, you're right, thumbnails are always jpg. Oh well, everyone settled on the alternative anyway.
"javascript: var imageLink = document.getElementsByTagName("a"); for (i = 0; i < imageLink.length; i++) if (/\/post\/show\//.test(imageLink[i].href)) imageLink[i].href = imageLink[i].firstChild.src.replace(/preview\//,''); alert('done');"
This is not working on my firefox.
AndarielHalo said:
"javascript: var imageLink = document.getElementsByTagName("a"); for (i = 0; i < imageLink.length; i++) if (/\/post\/show\//.test(imageLink[i].href)) imageLink[i].href = imageLink[i].firstChild.src.replace(/preview\//,''); alert('done');"This is not working on my firefox.
FFS, stop bumping this old thread already and use the other tool. Homo already pointed out the problem with my quickfix. I could throw in a few more lines to generate different extension variations (png, gif, swf) for every thumbnail to cover all the bases, but it isn't worth the effort.
If it still matters to you, the site HTML has changed since then for whatever reason. Replacing "firstChild" with "childNodes[1]" fixes your problem.
After a user prompted me about this, I realized this program can access more than one type of danbooru style site. Examples include gelbooru, sankakucomplex, 3d booru, etc.
Check in the list.pl file for a list of stuff that is supported. You should see something like this.
gelbooru=>sub{
use Booru::Gel;
Booru::Gel->new();
},
The bolded text is what you type in when you choose the type of booru to use. So it would look something like this.
perl booru.pl gelbooru ibuki_fuuko -r=3 -f=${md5} -p="C:\Pictures\Fuuko"
If the site you want is not there, you can probably edit the file/url to make it appear as long as you know the code or whatever that its written for.
I wish there was a post without bumping option.
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.
I found that by "dumping" the javascript with "childNodes[1]" then doing it again with "firstChild" works with all pictures from any time.
I'd greatly appreciate the code for PNG's and the like, but even then, I can still manage---I will get a 404 for wrong links, and can just replace the tag with the proper JPEG/PNG/GIF
Sometimes it doesn't work (something not being able to use a string as a hash ref). I suspect that this is due to amateur programming, and if someone who knows perl can take a look at it I'd appreciate it.
Try restarting windows as well while using it.
EDIT: I keep restarting it and then suddenly it works.
A very odd program.
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') + '<br>'; if (i%20 == 0) {document.body.innerHTML += newBody; newBody = "";} }; document.body.innerHTML += newBody; alert('done');
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.
Granola said:
Untrue, this happens even while I am logged in.
That's due to the nature of the script, as I do not believe it relies on cookies.
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
Thanks to seibastion for the fix, this was driving me crazy.
http://www.mediafire.com/?nwui2mqj2mk version 1.2 apparently working. You just need to plug in your login and password into it.
Thanks Granola for the help.
qqeor
1 year agoBatch download a tag set
I only want to batch download *one* collection of images for myself (I'm not gonna repost em or anything or abuse danbooru's BW). Are there any good tools for doing this?
I tried this:
http://code.google.com/p/danbooru-robot/
But it seems to be broken with the current version of Danbooru...
(If asking this is against some rule feel free to delete this)