Created
April 5, 2011 11:42
-
-
Save michel-slm/903448 to your computer and use it in GitHub Desktop.
iTunes feed extractor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import plistlib | |
import urllib2 | |
import sys | |
ITUNES_VER = '7.4.1' | |
USER_AGENT = 'iTunes/' + ITUNES_VER | |
def get_props(url): | |
request = urllib2.Request(url) | |
request.add_header('User-Agent', USER_AGENT) | |
response = urllib2.urlopen(request) | |
return plistlib.readPlistFromString(response.read()) | |
def get_feed(url): | |
props = get_props(url) | |
return props['items'][0]['feedURL'] | |
if __name__ == '__main__': | |
for url in sys.argv[1:]: | |
print get_feed(url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment