Revision: 1195
Updated Code
at September 22, 2006 06:33 by jacobian
Updated Code
#!/usr/bin/env python """ Create a SMIL file of all the full tracks from this week's All Songs Considered (http://www.npr.org/programs/asc/). """ import re import sys import urllib2 from BeautifulSoup import BeautifulSoup RA_URL = "rtsp://real.npr.org:80/real.npr.na-central/%s.rm" def allsongsallsongs(url): smil = ["<smil>", "<body>"] soup = BeautifulSoup(urllib2.urlopen(url)) for songlink in soup.findAll("a", {"href" : re.compile("getStaticMedia")})[1:]: rafile = RA_URL % songlink["href"].split("'")[1] smil.append("<audio src='%s' />" % rafile) smil.extend(["</body>", "</smil>"]) return "\n".join(smil) if __name__ == '__main__': if len(sys.argv) > 1: url = sys.argv[1] else: url = "http://www.npr.org/programs/asc/" print allsongsallsongs(url)
Revision: 1194
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 22, 2006 06:31 by jacobian
Initial Code
#!/usr/bin/env python """ Create a SMIL file of all the full tracks from this week's All Songs Considered (http://www.npr.org/programs/asc/). """ import re import sys import urllib2 from BeautifulSoup import BeautifulSoup RA_URL = "rtsp://real.npr.org:80/real.npr.na-central/%s.rm" def allsongsallsongs(url): smil = ["<smil>", "<body>"] soup = BeautifulSoup(urllib2.urlopen(url)) for songlink in soup.findAll("a", {"href" : re.compile("getStaticMedia")})[1:]: rafile = RA_URL % songlink["href"].split("'")[1] smil.append("<audio src='%s' />" % rafile) smil.extend(["</body>", "</smil>"]) return "\n".join(smil) if __name__ == '__main__': if len(sys.argv) > 1: url = sys.argv[1] else: url = "http://www.npr.org/programs/asc/" print allsongsallsongs(url)
Initial URL
Initial Description
Initial Title
All Songs All Songs
Initial Tags
python
Initial Language
Python