Revision 326639343661 () - Diff

Link to this snippet: https://friendpaste.com/2WmJT4RYpCJK0GQKYHWlLx
Embed:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# -*- 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)