Topic: Organizational Downloader

Posted under e621 Tools and Applications

I know there are a number of downloaders available for e621, but as far as I can tell, most of them are geared towards batch/pool downloads, which isn't specifically want I'm looking for. (Though I wouldn't be opposed to that being an option) So this post is a request for one of three things that fit what I'm looking for:
1. An existing tool that I've overlooked
2. Someone willing to throw together something
3. Someone to give me some coding advice and point me in the right direction to start creating such a tool myself

That said, what I need is a feature I've seen on both the Inkbunny Downloader and FA-Extended for their respective sites- a button to download the image on a post and automatically put it in a folder specifically for the artist in question. It makes organizing my saved images a hell of a lot easier.

Now granted, it could get a bit more complicated on e621 because of various posts having more than one artist tag listed, usually because of collabs and such. In those cases I imagine the best solution would be to either just take the first one listed, or open a popup window allowing the user to select which one to use. Or, possibly, even just save a copy into each applicable folder. (I wouldn't do that personally, but hey, someone else might.)

I could even potentially see something like this used to auto-save based on other tags as well, besides artist tags. But to be clear, I'm not talking about the "Go get all the images with such-and-such tag and download them" thing a lot of these tools seem to involve. What I'm looking for is something that puts a button on an individual image that I've opened, which will save it to the pre-determined appropriate folder when clicked.

So yeah, anyone know of such a thing, willing to make one, or at least point me in the right direction to try and make it myself?

Updated by hslugs

you could learn Python and hack together such a program in a month, including the time needed to learn the language. going to your nearest library and checking out an O'Reilly book is your first step.

Updated by anonymous

fewrahuxo said:
you could learn Python and hack together such a program in a month, including the time needed to learn the language. going to your nearest library and checking out an O'Reilly book is your first step.

Nah, he can do it with googles help, without having to learn it, too.
Take a piece from here, take a piece from there, put it together, patch it around. A bit of trial and error and done.

Updated by anonymous

LLoxie said:
a button to download the image on a post and automatically put it in a folder specifically for the artist in question.

I believe the only way to accomplish this is by making a browser extension. The language you will need to use for this is JavaScript, not Python.

Updated by anonymous

Thanks for the responses, guys. Yeah, I was kind of puzzled by the python suggestion too. I don't think any browser uses that for extensions...?

In any case, I take it nobody has something like that for e621 yet? Or maybe a good framework to build off of? I tried looking at the code for some other extensions, but it's kind of dizzying, heh.

Updated by anonymous

LLoxie said:
Thanks for the responses, guys. Yeah, I was kind of puzzled by the python suggestion too. I don't think any browser uses that for extensions...?

they don't. JavaScript, however, is one of the most poorly-designed languages you'll ever code in, where the language is not too bad as a whole, until you must deal with the dozens of niggling issues that pop up as you attempt to construct anything of any value. most of all, it's syntax, a lazy combination of old and new principles without the value of either.

the Python suggestion was in the event you demanded a dedicated downloader and not just an extension, which i see no mention of in your opening post. starting from scratch, it will take you a while to learn enough JavaScript to design your program's specifications. and to be honest, i don't know if the language has the capabilities you need, especially the "download to specific folders" bit.

Updated by anonymous

fewrahuxo said:
the Python suggestion was in the event you demanded a dedicated downloader and not just an extension, which i see no mention of in your opening post.

Well, I figured it went without saying, given the context. Especially seeing as how I mentioned a couple well-known extensions for other big furry sites as references. Speaking of which,

starting from scratch, it will take you a while to learn enough JavaScript to design your program's specifications. and to be honest, i don't know if the language has the capabilities you need, especially the "download to specific folders" bit.

There's no browser or language limitation for this- as I said, FA Extender does it just fine for FA, and InkBunny Downloader does it for Inkbunny. So it basically boils down to whether or not it's doable for e621, and while I'm obviously a bit green when it comes to this stuff, I imagine it's just as doable here. Trouble is I haven't seen one for e621 with that feature yet, and I feel like it'd be jumping well into the deep end trying to do it from scratch myself with no prior experience in making browser extensions. (Though, for the record, I'm not a complete stranger to programming; I just don't have an experience with JavaScript)

Updated by anonymous

I don't know the details of making browser extensions, but from what I understand, a basic one is just going to be a file with some JS and a file with some JSON formatted metadata.

I believe that triggering an image download and downloading to a specific folder without prompting the user are not things that can be done in plain JS so it must be something specific to the browser extension API that allows for that.

Anyway, here's some code to get you started:

(function() {
    'use strict';

    function processResponse(data) {
        var artists = data.artist,
            downloadURL = data.file_url;

        for(var artist of artists) {
            console.log(artist);
        }

        console.log(downloadURL);
    }

    function callAPI() {
        var url = window.location.href,
            postID = url.match(/post\/show\/([0-9]+)\//)[1],
            apiCall = 'https://e621.net/post/show.json?id=' + postID;

        var request = new XMLHttpRequest();
        request.open('GET', apiCall, true);

        request.onload = function() {
            if (request.status >= 200 && request.status < 400) {
                // Success!
                var data = JSON.parse(request.responseText);
                processResponse(data);
            } else {
                // We reached our target server, but it returned an error

            }
        };

        request.onerror = function() {
            // There was a connection error of some sort
        };

        request.send();
    }

    var saveButton = document.createElement('button');
    saveButton.textContent = 'Save';
    saveButton.style = 'margin: 4px 0;';
    saveButton.addEventListener('click', callAPI);

    var insertionPoint = document.querySelector('#remove-from-favs'),
        sBListItem = document.createElement('li');
    sBListItem.appendChild(saveButton); // only necessary because the insertion point is inside a list
    insertionPoint.insertAdjacentElement('afterend', sBListItem);

})();

When run on a post/show/ page it will make a button under the favorite button. Right now all the button does is retrieve the post's data from the site's API and then print the artists and image url to the console.

Updated by anonymous

purple.beastie said:
I believe that triggering an image download and downloading to a specific folder without prompting the user are not things that can be done in plain JS so it must be something specific to the browser extension API that allows for that.

Well, like I said, I know it's *somehow* possible, because I have extensions that do it for other sites. I tried looking at the code for one of them though, and it makes my head spin.

Anyway, here's some code to get you started:

(function() {
    'use strict';

    function processResponse(data) {
        var artists = data.artist,
            downloadURL = data.file_url;

        for(var artist of artists) {
            console.log(artist);
        }

        console.log(downloadURL);
    }

    function callAPI() {
        var url = window.location.href,
            postID = url.match(/post\/show\/([0-9]+)\//)[1],
            apiCall = 'https://e621.net/post/show.json?id=' + postID;

        var request = new XMLHttpRequest();
        request.open('GET', apiCall, true);

        request.onload = function() {
            if (request.status >= 200 && request.status < 400) {
                // Success!
                var data = JSON.parse(request.responseText);
                processResponse(data);
            } else {
                // We reached our target server, but it returned an error

            }
        };

        request.onerror = function() {
            // There was a connection error of some sort
        };

        request.send();
    }

    var saveButton = document.createElement('button');
    saveButton.textContent = 'Save';
    saveButton.style = 'margin: 4px 0;';
    saveButton.addEventListener('click', callAPI);

    var insertionPoint = document.querySelector('#remove-from-favs'),
        sBListItem = document.createElement('li');
    sBListItem.appendChild(saveButton); // only necessary because the insertion point is inside a list
    insertionPoint.insertAdjacentElement('afterend', sBListItem);

})();

When run on a post/show/ page it will make a button under the favorite button. Right now all the button does is retrieve the post's data from the site's API and then print the artists and image url to the console.

Thank you immensely for the code! It should help me start figuring things out somewhat.

Updated by anonymous

You're welcome. By the way, I just realized that DText broke the code a little. It removed the forward slash escapes from the regex in the line that starts postID = url.match(.

To correct it, replace * with backslashes: /post*/show*/([0-9]+)*//

Updated by anonymous

Well my take. Chrome/-ium only. Adds a green arrow button on the right side of the url bar, only active only e6 post pages.
Downloads to (download-folder)/e621/(artist-names)/(md5).(extension)

https://github.com/hslugs/e6dwl

To install, clone the directory, then in Chrome click burger -> More tools -> Extensions, enable Developer mode, click Load unpacked extension... and choose e6dwl directory.

Updated by anonymous

  • 1