Tuesday, May 27, 2008

Track Flickr group membership history using iMacro


User Guide
This script keeps a running log (every time you execute it), by updating a discussion message and/or saving a snapshot of group memberships. For the running log you have to create a message in each Flickr group you are an administrator for (or specifically declare), called "Member count". This log keeps a historical record of "date, membership total, total number of items". Before adding a new log entry it checks if the last entry (and the one before that) was less than a fortnight ago and updates it semi-intelligently.
Why?
I created this script as there is no easy alternative for keeping a history of membership for restricted groups in Flickr.
NotesI'm an administrator for 9 Flickr groups and maintain membership logs in 4 other groups. Watching the macro chug along updating the logs is quite satisfying. It takes 10 seconds per group (loading 3 to 4 web pages each time and added waiting time, to avoid possible page freezes, composes most of that time) but this can increase up to three-fold depending on Flickr traffic. For a macro that I only need to run once every one or two weeks that doesn't seem too shabby.

[Source code now maintained at Sourceforge.net]

iMacro setupiMacro installs itself with some example JavaScript files (.js) which are visible in the folders that iMacro shows you in Firefox.

If you find the location of these folders on your hard disk (on the Mac these are under /<your_username>/iMacros/Macros/) and then save the script in this location with a ".js" extension you should be able to see the file when you refresh the iMacro folder list in Firefox.

You should then be able to play the script from within iMacro (you have to already be logged in to your Flickr account and have created "Member count" discussion topics for groups you want to log). In the first instance I suggest you try the test test version which will run fully and show you the intended changes in the detailed change log but will not actually commit them.

See wiki.imacros.net for further help.

Monday, May 26, 2008

Flickr iMacro script to invite all your Flickr friends to a group

There was no automatic way to invite all your friends to join a group so I knocked up this quick script to take you from any group main page to the invite page, extract your list of friends (and no other contacts) and then send off the invite. The invite only goes to friends not yet in the group and not previously invited so you will not be bugging them with unwanted spam.

Note that more than 500 friends may result in time-out errors waiting for Flickr to respond. In this situation you may be better off inviting a few hundred at a time by recording an iMacro selecting the first checkbox on the invite page, then generalize it by removing the ATTR=NAME: and copy that line 200 times but change POS=1 to POS=R1 so that the next checkbox relative to the cursor position is ticked each time. When you've trimmed to a more manageable number then this script can apply again.

[JavaScript source code START]
/*
Description:
JavaScript for iMacro to create a block invite for all your
friends (but not family or other contacts) to join a Flickr group.
For more information see http://useroffline.blogspot.com

Assumptions:
- You have iMacro installed.
- You have your group's main page currently displayed.

Why:
There is no block invite facility built into Flickr.
*/

// Get friends list
var friendArr=new Array();
iimPlay("CODE:\
TAG POS=1 TYPE=A ATTR=TXT:Invite\n\
TAG POS=1 TYPE=A ATTR=TXT:Choose<SP>from<SP>your<SP>contacts?\n\
TAG POS=5 TYPE=TR EXTRACT=HTM\
");
// Tidy up extracted data
friendArr=iimGetLastExtract(1).split("name=\"");
friendArr.splice(0,1);
for(i in friendArr){
friendArr[i]=friendArr[i].split("\"")[0];
friendArr[i]="TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=NAME:"+friendArr[i]+" CONTENT=YES";
}
iimPlay("CODE:"+
"' Total no. of friends = "+friendArr.length+"\n"+
friendArr.join("\n"));
// Send the message
iimPlay("CODE:\
TAG POS=1 TYPE=INPUT:SUBMIT ATTR=NAME:Submit&&VALUE:PREVIEW*\n\
TAG POS=1 TYPE=INPUT:SUBMIT ATTR=NAME:done_send&&VALUE:SEND*\
");

[JavaScript source code END]

Thursday, May 22, 2008

Re-list books on Amazon using iMacro

User GuideThis script imports my Google spreadsheet of books and then pastes them to sell on Amazon books. It takes about 20 seconds to list each book but you only process those in your spreadsheet marked to be re-listed.
Example Google Spreadsheet.
Why?Unless you pay £28.75 per month to Amazon Books to become a professional seller, you don't get the facility to import from a spreadsheet. This iMacro code does exactly that, for free, though it is of course intended for smallish quantities (in practice I'm normally adding less than 6 books at a time and have less than 20 books up for sale).
Having recently realized that the handful of books I was trying to sell had not only all expired but had also permanently gone from my closed listings so I had to put them in from scratch, I had the incentive to spend a few hours playing with JavaScript and iMacro to find a decent work around.
Known Bugs
When I have more than 20 books the last ones on the list are ignored as already listed, probably due to export limitations with iMacro. My work around is to list new books at the top of the spreadsheet and it will work fine. You could also cut and paste previously listed books into a second page of the spreadsheet and keep the front page for new books to be listed.

Sunday, May 18, 2008

How to add a book title from an ISBN or ASIN in a Google spreadsheet

Having recently created an iMacro to import books from Google spreadsheet to Amazon, I realized that the formula I was re-using to automatically put in the book title was quite a neat feature of Google docs that most people are probably unaware of.

I use the importXML function. This finds data based on an HTML tag in any webpage and you can create that source webpage name as a formula. This gives a really neat way of cribbing data about a book straight from it's Amazon webpage to be used on your own spreadsheet (also known as website scraping).

Here's my example formula (assuming the ISBN or ASIN is at cell A1), read this as one line:
=importXML( concatenate( "http://www.amazon.co.uk/exec/obidos/ASIN/", A1), "//span[@id='btAsinTitle']")

By looking at the webpage source code for any Amazon book you can find HTML tags around all of the product data. In this case the HTML tag <span> with the ID attribute set to "btAsinTitle" surrounds the book title. If you wanted to grab data on the number of pages, publisher or even lowest second hand price, this is all possible in a similar manner.

I have also created neat formulas to grab best match full film title and release date from IMDB.com as a search sheet to support my DVD index so I can quickly cut & paste details based on typing in key words from the film title.

The only limitation is there is a maximum of 50 such formulas in any spreadsheet. However if you are building a catalogue or sales list, it is a fairly simple matter to cut & paste the values over the formulas for books or DVDs already indexed so only new entries use the formula.