#!/usr/bin/python
__version__ = "$Revision: 0.4 $"
__author__ = "Nicolas Seriot"
__date__ = "2009-06-08"
from re import *
from urllib import *
from getpass import *
import os
URL = "http://www.flickr.com/photos/bleve_349/sets/72057594113869693/"
FILE = "/Users/%s/Desktop/gallery.html" % getuser()
page = urlopen(URL).read()
regexp = compile("src=\"http://.*?\.static\.flickr\.com/(\d*)/(.*?)_(.*?)_(.)\.jpg\"")
re_title = compile("
(.*?) - a set on Flickr", DOTALL)
f = findall(regexp, page)
title = findall(re_title, page)[0]
urls = []
for i in f:
(a, b, c, size) = i
if size is 's':
url_med = "http://static.flickr.com/%s/%s_%s.jpg" % (a,b,c)
url_big = "http://static.flickr.com/%s/%s_%s_o.jpg" % (a,b,c)
urls.append((url_med, url_big))
s = []
s.append("""
%s
%s
""" % (title, title))
for (url_med, url_big) in urls:
s.append('\n' % (url_big, url_med))
s.append("""
""")
f = open(FILE, 'w')
f.writelines(s)
f.close()
os.system("/usr/bin/open \"%s\"" % FILE)