# -*- coding: utf-8 -*- from pyquery import PyQuery import subprocess import os dirname = '/Users/gawel/Music/NinjaTunePodcasts' pods = [ 'http://bigdada.com/podcast/rss.xml', 'http://www.coldcut.net/podcast.rss', 'http://www.ninjatune.net/ninjacast.xml', 'http://www.ninjatune.net/solidsteel/rss.xml', ] for p in pods: doc = PyQuery(p) for item in doc('item'): item = PyQuery(item) url = item('[@url$="mp3"]').attr('url') if url: title = item('title').text() if title: filename = os.path.join(dirname, '%s.mp3' % title) else: filename = os.path.join(dirname, url.split('/')[-1]) filename = filename.replace(' ', '_') cmd = 'wget -cO "%s" %r' % (filename, url) subprocess.call(cmd, shell=True)