FilesSubmittedBranchesLabelsClientsUsersJobsHelp
Tree viewShow/hide recent activityInformation
Change 95

Change 95 by zz9@zz9-imac-g4 on 2004/11/09 12:34:56

podgrab: urllib2 + a real User-Agent; two feeds 403 on Python-urllib. added my feed to the opml. also: Firefox 1.0 is out today. go get it. I'll wait.
Affected files ...
//depot/projects/podgrab/podgrab.py#3 editxtext
//depot/projects/podgrab/feeds.opml#2 edittext
Differences ...

==== //depot/projects/podgrab/podgrab.py#3 (xtext) ====

@@ -9,14 +9,19 @@
99import os
1010import shutil
1111import sys
12import urllib
12import urllib2
1313from xml.dom import minidom
1414
1515IPOD = "/Volumes/IPOD"
1616CACHE = os.path.expanduser("~/.podgrab")
1717SEEN = os.path.join(CACHE, "seen")
18UA = "podgrab/0.2 (+http://ttul.org/)"
1819
1920
21def fetch(url):
22 return urllib2.urlopen(urllib2.Request(url, headers={"User-Agent": UA}))
23
24
2025def read_opml(path):
2126 dom = minidom.parse(path)
2227 feeds = []
@@ -28,7 +33,7 @@
2833
2934
3035def enclosures(feed_url):
31 dom = minidom.parse(urllib.urlopen(feed_url))
36 dom = minidom.parse(fetch(feed_url))
3237 for item in dom.getElementsByTagName("item"):
3338 for enc in item.getElementsByTagName("enclosure"):
3439 yield enc.getAttribute("url")
@@ -61,7 +66,9 @@
6166 continue
6267 fname = os.path.join(CACHE, os.path.basename(enc))
6368 print " ", enc
64 urllib.urlretrieve(enc, fname)
69 f = open(fname, "wb")
70 shutil.copyfileobj(fetch(enc), f)
71 f.close()
6572 out.write(enc + "\n")
6673 if os.path.isdir(IPOD):
6774 # NB: this does not update the iTunesDB. use gtkpod, or

==== //depot/projects/podgrab/feeds.opml#2 (text) ====

@@ -9,5 +9,6 @@
99 <outline text="The Geek Hour" type="rss" xmlUrl="http://geekhour.example.com/rss.xml"/>
1010 <outline text="Kernel Panic Radio" type="rss" xmlUrl="http://kpr.example.net/podcast.xml"/>
1111 <outline text="Pacific Northwest Hacker Hour" type="rss" xmlUrl="http://pnwhh.example.org/feed/"/>
12 <outline text="zz9 talks about stuff" type="rss" xmlUrl="http://ttul.org/~zz9/podcast/rss.xml"/>
1213 </body>
1314</opml>

P4Web/LINUX26X86/2005.1/82295 · Copyright © 1995-2005 Perforce Software · ttul.org