Bionus / imgbrd-grabber

Very customizable imageboard/booru downloader with powerful filenaming features.
https://www.bionus.org/imgbrd-grabber/
Apache License 2.0
2.42k stars 212 forks source link

Add javascript validation to the filename window #213

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 9 years ago

after a hiatus, I finally tried again the Javascript naming features and got a few problems.

  1. first, if ever you make a single mistake in your javascript code, you get an error message when you try to download. the problem is that you get an error message for each file that is on the batch list! if you have 1000 images, you get 1000 error messages.
  2. my second problem is with the javascript I want to use: javascript:search_1[0] + '\\' + search_1.replace('_', ' ') + '\\[' + artist.replace('_', ' ') + '] ' + website + ' ' + id + ' (' + copyright.replace('_', ' ') + ' (' + character.replace('_', ' ') + ')).' + ext with this line, I try to remove every single '_'(underscore) with 'space'. But, up to now, grabber only replace the very first underscore for each token. here is the kind of result I get for Copyright and Character tokens : dragon quest+dragon_quest_iii (mage (dq3)+priest_(dq3)) original+yuusha to_maou (nise maou_kanizeru) As you can see, only the first underscore for each token is removed.

Is there a problem in my javascript code? how could I fix that?

Thanks keep up the good work!

Original issue reported on code.google.com by ser...@hotmail.com on 25 Mar 2013 at 4:11

GoogleCodeExporter commented 9 years ago

Update about '2.' I found the fix myself on the web instead of ('',' '), I used (//gi, ' ') that took care of every single underscore in all the token answers.

Thanks netherless^^ keep up the good work

Original comment by ser...@hotmail.com on 25 Mar 2013 at 4:25

GoogleCodeExporter commented 9 years ago

First, it seems like Javascript currently has a major flaw with the replacing of forbidden characters. I'll release an alpha version tonight or tomorrow (UTC+9) to fix this as well as danbooru 2.0.

  1. I therefore advice checking the validity of your Javascript code beforehand. Because even if I change the error message behavior, the remaining problem will be that all the images are downloaded for nothing. I'll add a validity checker however (same as the one for the tokens), so you'll be able to see in real time if there is an error in your code (but maybe not in the upcoming alpha version).
  2. Indeed, replace('string') will only replace the first occurence, while replace(/regex/) will replace them all. By the way, /_/gi can be replaced by /_/g (the i stands for "case insensitive", but an underscore doesn't has case). It doesn't really changes anything, but well. ^^

Original comment by bio.nus@hotmail.fr on 26 Mar 2013 at 2:20

  • Changed state: Started