Serotonin Storm

About

The opensource blog of Justin Quick discussing software/web development, security, and general techie goodness. read more...

Subscribe

Categories

Recent Posts

Digital Blasphemy - Blasphemy

Capturing Digital Blasphemy's free gallery
Aug. 11, 2009
Photography, Python, Web,

I love the site Digital Blasphemy and the photos they produce. The best feature of their site is their free gallery section which provides a lot of their premium content for free. They rotate this collection often, so there are always new impressive images. On the site they are nice, but I wanted all of them on my desktop without paying for their service.

The solution I came up with is this python script that follows. It grabs all the images from their free gallery and downloads them into your Pictures folder.

#!/usr/bin/env python

from urllib import urlopen, urlretrieve
from os import path

site = 'http://digitalblasphemy.com'
ddir = path.expanduser('~/Pictures/')
find = lambda s,p: s.find(p) > -1
width = '1280'

for l in urlopen('%s/freegallery.shtml' % site).readlines():
    if find(l, 'w=%s' % width):
        for u in ['%s/fshow%s' % (site, x.split('">')[0]) \
         for x in l.split('fshow') if find(x, 'w=%s' % width)]:
            for xl in urlopen(u).readlines():
                if find(xl, 'width="%s"' % width):
                    p = xl.strip().split('src="')[1].split('"')[0]
                    fn = path.join(ddir, path.basename(p))
                    if not path.isfile(fn): urlretrieve(site+p, fn)

Short, sweet, and completely unintelligible. Just be glad it works. Also for those of you playing along at home, that runs in O(N4), which his absolutely horrendous, but performance was not a huge concern since it takes about all of 3 seconds to fetch every image. And the results speak for themselves

I personally put this script into a cron job and run it every so often. It dumps the images into my Pictures folder, which I set my desktop background to randomly rotate through. They do not update their free gallery very often, but its a nice surprise to see an awesome backround appear out of no where.






blog comments powered by Disqus