RB Inventory A (Art) by Marjolein Katsma
A set of scripts with which a RedBubble member can create a complete inventory of all their public art on RedBubble.
Bookmark and Share

What is this?

RB Inventory A is a set of scripts with which a RedBubble member can create a complete inventory of all their public art works on RedBubble, with title, description, all tags, and other useful meta data.

The inventory can be imported into a spreadsheet, a database, or be used as the source data for future scripts.

Current version: 1.0 - 2010-09-05

What does it do?

RB Inventory A goes through your public Art pages (as many as you let it in one go), and records:

  • The page address (URL)
  • A work (page) ID (derived from the URL): internal RedBubble ID without a sequence number
  • All items in the 'Information' box on the Edit page, including original name of the uploaded image file
  • All textual information from the Edit form:
    • title
    • description in RedBubble markup format
    • all tags
    • the state of each of the media checkboxes
  • The description again as rendered in HTML format
  • A timestamp of when all this data was gathered

The description is written to two separate files, both with the ID as the name part; the RedBubble format is stored in a .txt file, the HTML is stored in a .html file.

All other data is stored as a single record in a file in CSV format, which can easily be imported into a spreadsheet or database.

Note that this script cannot store an image thumbnail, because that is not found on an individual work page. Another script (to be developed) may provide this functionality, storing thumbnails also using the ID as file name, so it can all be tied together.

What do you need?

Note: There are different scripts (because page layouts differ) for Art, Calendars, Clothing and Writing. You can get only the ones you really need (download them from their respective pages), or download them all as one complete package from the RB Inventory page.

To use any RB Inventory A script, you basically need three pieces of software:

  1. The Firefox browser, version 3.0 or higher. Free, open source software.

    Apart from Firefox, you also need 256MB of RAM (512MB recommended) and at least 10 MB of available hard-disk space.

  2. The iMacros Extension for Firefox, version 6.7 (current production release) or higher. Free (as in beer), but not Open Source.

  3. Download RB Inventory A - this is a ZIP archive.
    Current version:
    1.0 - 2010-09-05

    The actual RB Inventory A package.

    Once you've downloaded the archive, extract it into the iMacros 'Macros' folder (for which you've noted the path in the previous step).

    This package consists of 6 files:

    RB_Inventory_A.js
    a JavaScript script that calls the RB_Inventory_A.iim macro once for each Art page and writes the inventory data files
    RB_Inventory_A.iim
    the iMacros macro for Art pages
    RB_back.iim
    a small macro to go back to the previous page
    RB_refresh.iim
    a small macro to reload the current page
    RB_pubdtc.iim
    a small macro that makes sure the script working on a public view page
    LGPLv3.txt
    the text of the license

Once you have extracted the ZIP package(s), you can start iMacros again: you can check whether the files mentioned above are now actually visible in the file list at the top. (If not, go back and repeat the last step!)

How does it work?

RB Inventory A works exclusively on your public Art pages, including the Edit page for each: that means you not only must be a RedBubble member, but you must also be logged in for the script to be able to do its work. You have to navigate to a page to start at (initially, your first visible page with your latest work) before starting the script; the script will follow the 'Next' links to navigate from page to page.

The (JavaScript) file RB_Inventory_A.js 'drives' the process; when you start it, it first picks up the configuration variables (see Preparation below), and then loops (at most) the configured number of times, calling the (macro) file RB_Inventory_A.iim to pull the actual values from each page and pass them back to the calling script. The script then massages the gathered data a little and adds one record to the CSV file and writes two separate files with the art description of the just processed page, before calling the macro again for the next page.

For each page, the script notes the art ID (at RedBubble) - this is guaranteed to be unique - and not only records this in the record in the CSV file, but also uses it as the file name part of the files with the work's description: thus all this data is 'tied together' via this ID. (Future scripts will also make use of this ID.)

The script always stops with the next page to be processed already loaded, so you can continue from there by just restarting the script: this allows you to do the whole job in smaller 'batches'. If there are no more pages to be processed (no 'Next' link), the script stops on the last page.

Because the script goes through the pages sequentially, and can be used to process them in batches, you should not make any change to the ordering of your pages between batches (let alone while the script is working!), or you risk missing pages and getting double information for others.
On the other hand, if you add new pages and leave them at the front, the script can be easily configured to pick up only the newest files and add their data to the inventory - see the How to use section for details.

Preparation

Before you can start to use RB Inventory A you will need to do two things to prepare for it:

  1. Create an empty directory where you have write permission. This is where your inventory files will be created.

    On Windows, the best way is to create a subdirectory in your personal 'Documents' directory; if you call that subdirectory 'RB_Inventory_A' (recommended: match the script name), the path will look similar to this:
    C:\Users\YOURNAME\Documents\RB_Inventory_A.

    On Linux or OS X, create a directory somewhere under your HOME directory, and make sure it can be written to.

  2. Configure the script.

    Once you have created your output directory, you'll need to 'tell' the script where this directory is, plus a few other things. For now, you'll have to do that by editing a few lines in the configuration section of RB_Inventory_A.js.

    You can do the editing from within iMacros:

    • In Firefox, open the iMacros user interface by clicking the iMacros button (left of the adress bar).
    • In the files list (top half of the side bar), find and highlight the file RB_Inventory_A.js
    • Then, below that in the tabbed interface select the 'Edit' tab: you will see an 'Edit Macro' button at the top. (If no file is highlighted, the button is disabled.) Press the button to edit the file.
      (The default editor on Windows is Notepad, but if you prefer another editor for editing code, you can configure it via the 'Options' dialog, also found on the 'Edit' tab.)
    • With the file in the editor, scroll down till you find this marker line:
      /* ---------- Configuration ---------- */
      Between that line and the next marker line are 7 variables you can configure (see next step); do not edit anything beyond the next marker line:
      /* ---------- END Configuration ---------- */
    • Make sure you edit only values between the double quotes, and don't touch the rest of the line!
      1. First and most important is the variable outputdir: it must be set to the full path of the output directory you created. Note that on Windows you must double all backslashes instead of using single ones for the path separator (as the example value in the code demonstrates). Also, on all platforms, the value must end with a path separator: a double backslash for Windows, a single forward slash on other platforms.
        On Windows, the example path shown above will now look like this:
        C:\\Users\\YOURNAME\\Documents\\RB_Inventory_A\\.
      2. The next two variables are the filenames for the output file (outputfile, the CSV file the script will create) and a file where any errors are reported (errorsfile). These must be just file names (not paths), but you can safely leave them as they are. At least make sure the name of the outputfile ends in .csv to enable importing it into a spreadsheet.
      3. Then there is the variable utf8; this is by default set to true which means writing non-ASCII characters is supported. Strongly recommended to leave this as is.
        (If you do edit this, make sure to not add quotes; this must be an unquoted value!)
      4. The timeout value is already set at the default of 60 seconds. However, when the script detects an error situation possibly caused by a timout, it will increase its timeout setting and try again. If you already know you have a slow system and/or slow internet connection, you may want to start with a higher value. The script will also tell you at the end of a batch what value it ended up with: you could use that as the initial value for your next batch. See also Timeouts in Known Problems below.
      5. The final two variables you may configure are maxloop and stopat. Leave them as they are now - we'll get to them after the first test.

    When you have made all necessary changes, save the file. iMacros will automatically get the new version.

First test

Now, you will need to test whether the script actually runs and can write the necessary data to your computer.

If you made any mistake in editing the configuration part of the script, JavaScript will throw an error; this may be shown in the message area of the iMacros user interface (the green background turns whitish and the text may look quite cryptic), or in a popup dialog. Go back to step two of the Preparation section.

If the configuration is done correctly, the script will start, but it will first test whether data can actually be written. If not, the script will pop up a message, and stop. The cause will most likely be a problem with write permissions of the directory you designated for the data. Go back to step one of the Preparation section, and make sure that 1) the directory actually does exist and 2) it has enough write permissions for the script (Firefox) to be able to create files in it.

Do the test:

  1. Open Firefox, or if it is already open, open a new window (you could open a new tab, but it's better to work in a separate window).
  2. Now open your RedBubble profile in it, make sure you are logged in, and then open your first art page in Public View mode (i.e., from your Profile page, just click on the first item in your 'Art' block).
  3. Click the iMacros button to open the iMacros user interface next to your writing page. In the tabbed dialog (lower half), select the 'Play' tab.
  4. Now, scroll to find the RB Inventory A files above, and highlight the file RB_Inventory_A.js. The 'Play' button will become enabled.
  5. Press the 'Play' button and watch!
  6. If any error is reported, either in the iMacros interface, or in a popup dialog, see above and double-check your Preparation steps; then try again.
  7. If the script runs correctly, it will stop at the next art page, and pop up a dialog to report how many pages have been processed. (If you left the variable maxloop alone, that should be just one - enough for the initial test!)
  8. Now check your output directory: there should be your CSV file (default name RBInventory_A.csv) and there should also be two files with the work's ID as the file name part. You should open them to check their contents.
    You should not see any #EANF# strings anywhere; that string means the script was not able to pick up some variable (possibly as a result of a timeout).
  9. All OK? then you're ready to run!

How to use

There are a few use cases, described below. In general, before running the script (especially if yo need to run it on a large number of pages), make sure it gets as much CPU and memory as possible. That means preferably rebooting your machine, and closing down other applications (something like a renderer running in the background will not help with the speed of the script and neither will a backup program suddenly starting up!) It can also be helpful to (temporarily) disable any other extensions you have installed in Firefox and which may 'on their own' start to do something; an example is the (otherwise excellent) Xmarks extension. So go through your applications, close what isn't needed, disable some extensions, and restart Firefox.

Now, hang on to your inventory, and maintain it - more scripts will come to make good use of it! Meanwhile, you can directly open the CSV file into a spreadsheet (or import it into a database), and see what you have!

Known problems

These are currently known problems, and what you may be able to do about them.

Since this section probably will apply to all RedBubble and Identica scripts, this section will be moved to a separate page!

Timeouts

Summary

Puzzling symptoms: Some early testers and users of the first RB Inventory script reported various problems that mystified me at first - especially since I had not seen any of that on my own two machines that I tested on (one reasonably recent an fast machine running Windows Vista, and one very old one running Windows 2000). Only when several reports came in did I start to see a pattern in the various symptoms: batches not completed, but bailing out at a much lower number than the configured loop variable, a page URL not extracted, missing data, the script 'thinking' it had reached the last public image page when it was nowhere near yet... all of those symptoms could actually be caused by a timeout: the iMacros script stopping to wait for a page to load when its (built-in) timeout was reached, and then carrying on trying to get data that simply wasn't there. And as I later realized, it wasn't necessarily the script timing out: a browser has a timeout too...

Problems or bugs?

If you are getting really stuck, or if you think you found a bug, you can contact me by BubbleMail (this link will only work if you actually are a RedBubble member and are logged in), or via my contact form. The first option is by far the best and you may reach me sooner, but please remember that I do not watch my bubble mail every hour of the day...

Of course, if you have any brilliant ideas for improvement or possible new scripts, also let me know. No guarantees as to feasibility, but I'll certainly consider your valuable suggestions. Or, since it's all Free, Open Source Software, you may want to make your own changes or additions, and share those with the world! Please make sure to actually read the license included in the package before you plan to distribute any modifications!