Download an entire Picasa Web Album in Full Resolution

I'm on Linux and Google stopped developing Picasas for Linux (well, they never did, they just had the Windows version running under Wine). Nevertheless, I wanted to download a complete Web Album in the highest possible resolution.

Unfortunately, Picasa has recently changed the URL structure, so that the trick with DownThemAll and the RSS feed does not give you the full size anymore. Here is a simple, but ATM working, solution: Click on the RSS link as usual, but don't use DownThemAll. Instead, save the page as HTML. If you open the file in a text editor, it's one very very very long line of HTML code. Now comes the fun part: A simple Python script that parses all URLs, replaces the size restriction but the full size URL and downloads the pictures.

#!/usr/bin/env python2

import sys
import urllib

def download(url):
    webfile = urllib.urlopen(url)
    localfile = open(url.split('/')[-1],'w')
    localfile.write(webfile.read())
    webfile.close()
    localfile.close()


if len(sys.argv) < 2:
    sys.exit()
    
fn = sys.argv[1]
fp = open(fn, 'r')
content = fp.readline()
contents = content.split("><")
count = 0
print len(contents)
urllist = []
fnlist = []
for line in contents:
    if line.startswith("media:thumbnail"):
        url = line.split(" ")[1].split("=")[1][1:-1] # Ugly, but seems to work
        print "Found Picture: " + url
        fname = url.split("/")[-1]
        if fname not in fnlist:
            fnlist.append(fname)
            urllist.append(url)
            
print "Found " + str(len(urllist)) + " Pictures, downloading them now in Full Resolution, if possible..."
for url in urllist:
    dlurl = url.replace("s288", "s0")
    dlurl = dlurl.replace("s72", "s0")
    dlurl = dlurl.replace("s144", "s0")
    print "Downloading " + dlurl + "..."    
    download(dlurl)

Maybe it's usefull for someone…