1 1 * * * /Users/gfranxman/Pictures/ScreenSaver/ss.py
posted: 2008-04-05 02:35:56 perma-link, RSS comments feed
We just launched the new MetroPulse and I'm still in the 'keep an eye on it' mode. The site looks great and will only improve as we round out the features and their staff get more content plugged in.
One of my favorite things about the MetroPulse is their photography. And one of my favorite things about my desktop computer is that it's a mac. And one of my favorite things about macs is the unix underpinnings of OS X. And one of my favorite things about OS X is that it ships with python.
I had to do something about that.
First, I created a folder under my Pictures folder called ScreenSaver.
In there I created ss.py which contained this wonderfully simple python script:
#! /usr/bin/python import os from urllib import URLopener from urllib2 import urlopen from xml.dom.minidom import parseString rss_url = 'http://www.metropulse.com/feeds/photos/' dst_dir = os.path.expanduser('~/Pictures/ScreenSaver/' ) fd = urlopen( rss_url ) src = fd.read() fd.close() dom = parseString( src ) for i,e in enumerate( dom.getElementsByTagName( 'item' ) ): enclosure = e.getElementsByTagName( 'enclosure' )[0] link = enclosure.getAttribute( 'url' ) mime = enclosure.getAttribute( 'type' ) ext = mime[ mime.index('/')+1:] URLopener().retrieve( link, filename="%s%s.%s" % (dst_dir,i,ext) )
Next I created a new file called sscron to run hold a schedule for running that python script:
1 1 * * * /Users/gfranxman/Pictures/ScreenSaver/ss.py
( If you are playing along at home, you'll need to change the 'gfranxman' to your own user name. )
And then I marked the script executable, gave a whirl, and installed the schedule by opening the terminal executing:
$ chmod u+x ~/Pictures/ScreenSaver/ss.py $ ~/Pictures/ScreenSaver/ss.py $ crontab ~/Pictures/ScreenSaver/sscron
Finally, I opened the system prefereces, went to the ScreenSaver preferences and clicked 'Choose Folder'. After selecting my Pictures/ScreenSaver folder, I now a screen saver of the latest 20 photos posted to the MetroPulse website, refreshed daily and displayed with that gratuitous Ken Burns effect.
Glenn commented, on April 5, 2008 at 10:05 a.m.:
OK, I've pumped up the contrast on the code sections.
Re: macs == satan
Come on, you're the one who got me started on Apple. Indirectly, this is all your fault!
Justin commented, on April 6, 2008 at 9:25 a.m.:
I'm only commenting because I'm curious what my avatar will look like.
Clark commented, on April 7, 2008 at 12:09 p.m.:
macs <> satan
Jobs == satan
Now that I can read your code I feel inferior for not understanding it. Make it dark and illegible again so as to spare my frail psyche.
Ryan commented, on April 7, 2008 at 1:51 p.m.:
Could this script work with a Flickr RSS feed? The code looks easy enough to modify (from my non-programmer perspective) to work with Flickr...
Glenn commented, on May 3, 2008 at 5:08 a.m.:
I imagine it would work with flickr -- there are lots of flickr screensavers out there.
Right now, I'm geeked on finally getting some code highlighting working on here.
Keith commented, on January 3, 2009 at 9:59 p.m.:
Thanks for this script - just what I was looking for!
James commented, on January 30, 2011 at 9:54 p.m.:
I tried it with this RSS feed:
http://instagr.am/tags/thespoiledbutterf...
james-macbook:~ james$ chmod u+x ~/Pictures/ScreenSaver/ss.py
james-macbook:~ james$ ~/Pictures/ScreenSaver/ss.py
Traceback (most recent call last):
File "/Users/james/Pictures/ScreenSaver/ss.py", line 25, in <module>
enclosure = e.getElementsByTagName( 'enclosure' )[0]
IndexError: list index out of range
Any suggestions? Thanks!!
Sandra commented, on September 20, 2012 at 9:58 p.m.:
This device sonuds useful at first, however its limited functionality and high rental prices render it completely unworthy of its retail price. First off, the only television networks allowing show rentals at launch on the Apple TV are ABC (Disney) and Fox, and there is no guarantee that any more networks will get on board in the future. (Of course, Apple is counting on using the likely large number of Apple TV sales to force other networks into allowing rentals on the device as well.) Even if more networks do become available on the device, you will only be renting, not buying your content, which means that the Apple TV is hardly anything more than an elegant TV show and movie rental device. While there are numerous movie choices, the $4.99 rental price is ridiculously expensive compared to other movie rental services, such as redbox or Netflix (which this device surprisingly supports). Sure, the $99.00 price sonuds good now, but the expenses will quickly add up if you plan to use the Apple TV for its main purpose, renting movies and television shows from the iTunes Store. While this can stream music from your iTunes library and photos from your computer, that is about all it can stream (in addition to content from a limited number of sites, such as YouTube, Flickr, and Netflix). If you have a Mac and want to stream videos from your computer to your Apple TV, you had better hope they are in the .m4v, .mp4, or .mov formats, otherwise they will not play. The ability to stream videos from your computer to your TV is nice, but the number of formats supported is so limited that this feature is relatively useless (unless your video library is in Apple-approved formats).To sum it up, this is nothing more than an attractively designed video rental box that is touted as something much more useful than it actually is. If you are looking for something that looks cool but that does nothing but increase iTunes profits and stream what media content Apple deems as acceptable to your TV, then this is the device for you.
ncdigjx commented, on September 21, 2012 at 10:52 a.m.:
NUU61A <a href="http://cfaecepwkyky.com/">cfaecepwkyky</a>
idjhrfafjah commented, on September 22, 2012 at 4:24 p.m.:
t8ZZet <a href="http://vfwfhhroczpz.com/">vfwfhhroczpz</a>
100% real jordans for cheap commented, on January 7, 2018 at 6:32 a.m.:
I want to get across my appreciation for your kindness for those individuals that really need help on this particular idea. Your very own commitment to getting the message all-around has been astonishingly insightful and has surely helped associates like me to attain their objectives. Your entire valuable suggestions indicates a lot to me and much more to my office workers. Thank you; from each one of us.
[url=http://www.jordansforcheap.us.com]100% real jordans for cheap[/url]
Based upon your reading habits, might I recommend: Or, you might like: |
hosting: slicehost.com.
powered by: django.
written in: python.
controlled by: bzr.
monsters by: monsterID.
You've been exposed to: {'Programming': 1}
Clark commented, on April 5, 2008 at 8:47 a.m.:
Dude... Not that I would understand it if I could see it... but black text on a dark gray background is a tad difficult to read.
MetroPulse looks cool...
Macs are spawn of the devil... and not the cool robot devil.