Build Gallery - Is there a more detailed FAQ/manual?

Ask for help about FlashGot, no registration needed to post
Post Reply
Gliktch
Posts: 8
Joined: Fri Oct 09, 2009 9:56 pm

Build Gallery - Is there a more detailed FAQ/manual?

Post by Gliktch »

Hello,

I'm attempting to download from a site which orders its files like this:

h++p://www.somesite.com/folder/001/1a.jpg
h++p://www.somesite.com/folder/001/2a.jpg
h++p://www.somesite.com/folder/001/3a.jpg
h++p://www.somesite.com/folder/001/4a.jpg
h++p://www.somesite.com/folder/001/1b.jpg
h++p://www.somesite.com/folder/001/2b.jpg
h++p://www.somesite.com/folder/001/3b.jpg
h++p://www.somesite.com/folder/001/4b.jpg
h++p://www.somesite.com/folder/001/1c.jpg
h++p://www.somesite.com/folder/001/2c.jpg
h++p://www.somesite.com/folder/001/3c.jpg
h++p://www.somesite.com/folder/001/4c.jpg
h++p://www.somesite.com/folder/001/1d.jpg
h++p://www.somesite.com/folder/001/2d.jpg
h++p://www.somesite.com/folder/001/3d.jpg
h++p://www.somesite.com/folder/001/4d.jpg
h++p://www.somesite.com/folder/002/1a.jpg
h++p://www.somesite.com/folder/002/2a.jpg
h++p://www.somesite.com/folder/002/3a.jpg
h++p://www.somesite.com/folder/002/4a.jpg
h++p://www.somesite.com/folder/002/1b.jpg
h++p://www.somesite.com/folder/002/2b.jpg
...etc

If I can get the gallery to generate in the correct order, then my download manager will also grab them in the right order... thus if I then sort the destination folder by file date, things'll be peachy without having to rename anything after the fact. I do know enough javascript to write the half-dozen lines of code to generate the desired gallery in less time than I've just spent searching for a flashgot-oriented answer to this problem, though I have to consider the big-picture time gains of learning to use this very excellent add-on to its fullest ;)

If you could please lay out the basic steps to getting something like this working with a javascript function within Flashgot, that might serve as an easy enough example for others to follow (I couldn't see any examples of javascript functions for Build Gallery on these forums, after looking through all 4 pages of results for the search term 'gallery'). I'm off to write that self-serving code now, but I'll definitely check back for the real answer at a later date :D
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6
Gliktch
Posts: 8
Joined: Fri Oct 09, 2009 9:56 pm

Re: Build Gallery - Is there a more detailed FAQ/manual?

Post by Gliktch »

Found info in this thread that is enough for me to work it out - it would probably be a good idea to give a quick step-by-step in the FAQ though, something like:

- Reference (include) your new function name in the Preview/Content field(s) of the Variable URLs panel
- Switch to the JavaScript Functions panel and write the function code
- ???
- Keep an eye on the bottom pane which notifies you of things like obvious syntax errors
- Switch back to the Variable URLs panel and check your results before generating
- ???

I leave the ???'s since I still don't know how you do things like set global variables (outside the function's bounds), though I guess that could be achieved fairly easily with a workaround (setting a second variable "isdefined" or whatever, or using a native function for that).. Actually on that point I think I'm imagining problems where there are none.. I'm just thinking of the situation in webpage scripting where often you want to set some variables the first time the page is loaded, then your functions use those values for starting loops etc..? So you set them outside the bounds of the function's braces. Like I said, probably a non-issue, I'll have to have a play with this feature and if there is any real problem there I'll be sure to post again :)

Cheers!
- Matthew
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6
Gliktch
Posts: 8
Joined: Fri Oct 09, 2009 9:56 pm

Re: Build Gallery - Is there a more detailed FAQ/manual?

Post by Gliktch »

Okay... I tried the following syntax in the Variable URLs:

Code: Select all

h++p://www.somesite.com/folder/[001-005;1]/[1-4][abcd("a","b","c","d")].jpg
And the following code in function "abcd":

Code: Select all

if (window.x === undefined) var x=0;
return(arguments[x]);
if (x<3) x++; else x=0;
The first line is used to set the x variable the first time; I also tried without the "window." since different sites say different things about testing whether or not a variable has yet been declared... In this function when x=0 it should return "a", up to x=3 returning "d", then starting over again...

What am I doing wrong? It doesn't work at all, it seems like the function is being ignored and the gallery generation is using the [abcd("a","b","c","d")] part as explicit text and not a function.

EDIT: Okay, I got it worked out :) Or at least, I got to the point where Flashgot is actually using my function (I just realized I hadn't actually implemented the 'stepping' yet, and the above code does the same as a simple [a-d] range)...

My updated code is like this:

Code: Select all

if (x === undefined) {var x=0; var n=1;}
if (n < 4) {return(arguments[x]); n++}
else {n=1; if (x<3) x++; else x=0;}
But now that function is only returning A's (the first argument, meaning x is always returning as 0, probably due to the check in the first line always returning true) - any suggestions on how to set a one-time variable and not have it continually overwritten by its own declaration? :/

Third try:

Code: Select all

if(!x){var x=1; var n=1;}
if(n<4){return(arguments[(x-1)]); n++}
else{n=1;if(x<4){x++;}else{x=1;}}
Same result (only ever returns the first argument, "a")

Thanks for any help,
- Matthew
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6
User avatar
Giorgio Maone
Site Admin
Posts: 9524
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: Build Gallery - Is there a more detailed FAQ/manual?

Post by Giorgio Maone »

Gliktch wrote: If I can get the gallery to generate in the correct order, then my download manager will also grab them in the right order...
I guess this is the reason why

Code: Select all

http://www.somesite.com/folder/[001-005;1]/[1-4][a-d].jpg
won't work for you, right?

Then please Try this as a range:

Code: Select all

http://www.somesite.com/folder/[001-005;1]/[abcd([0-15])].jpg
and this as the abcd() function body:

Code: Select all

var n = arguments[0];
return (n % 4 + 1) + String.fromCharCode(97 + Math.floor(n / 4))
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6
Gliktch
Posts: 8
Joined: Fri Oct 09, 2009 9:56 pm

Re: Build Gallery - Is there a more detailed FAQ/manual?

Post by Gliktch »

You are a scholar and a gentleman, thanks muchly ;)
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6
Post Reply