import static groosh.Groosh.groosh
import static org.codehaus.groovy.groosh.stream.DevNull.devnull
ids = [:]
shell = groosh()
//get all images in this folder and upload it to flickr
//remember the photo id we get from flickr
println "Uploading file $it to flickr"
flickcurl = shell.flickcurl("upload",it,"friend","family")
id = flickcurl.grep(~/.*Photo ID.*/).split(":").trim()
ids[it] = id
println "Photo ID is: $id"
//we need to know the first photo id
firstKey = ids.keySet().toList()
//create a set with the name of the directory we are in right now
//use the id of the first photo as set cover
setName = shell.pwd().text.split("/")[-1]
println "Creating set: $setName"
flickcurl = shell.flickcurl("photosets.create",setName,setName,ids[firstKey])
id = flickcurl.grep(~/.*Photoset.*/).split(" ").trim()
println "Photoset ID is: $id"
//make a backup of the ids in a file for later reference
println "Writing ids to a file"
file = new File(shell.pwd().text.trim() + "/.flickrset")
file << "Photoset:" << id << "\n"
file << it.key << ":" << it.value << "\n"
//the first photo is allready part of the photo set so lets remove it
//add the remaining photos to the photo set
println "Adding photo to set at flickr: $it"
shell.flickcurl("photosets.addPhoto",id,it.value) | devnull()
Friday, March 28, 2008
Uploading Images to Flickr using flickcurl and Groovy
For the latest Groosh release I created an more elaborate example of how to use Groovy and Groosh. This example shows how to upload Images to a Flickr account using Groovy, Groosh and flickcurl.