]> code.delx.au - monosys/commitdiff
Small improvements
authorJames Bunton <jamesbunton@fastmail.fm>
Mon, 18 Jul 2011 14:38:33 +0000 (00:38 +1000)
committerJames Bunton <jamesbunton@fastmail.fm>
Mon, 18 Jul 2011 14:38:33 +0000 (00:38 +1000)
scripts/sbs-downloader

index f3a0385311732c8b114487041703b80b4181dd07..1c3d9fb49ccf693772e26194399778a1bb7de207 100755 (executable)
@@ -64,7 +64,7 @@ def get_video_list(playlist_url):
        playlist = grab_xml(playlist_url)
        for video_desc in playlist.xpath("//video"):
                video_desc_url = video_desc.xpath("@src")[0]
-               title = video_desc.xpath("title/text()")[0]
+               title = video_desc.xpath("title/text()")[0].strip()
                video_list[title] = (title, video_desc_url)
        return video_list
 
@@ -107,11 +107,15 @@ def download_rtmp(filename, vbase, vpath):
 
 def download_urllib(filename, url):
        print "Downloading: %s -> %s" % (url, filename)
-       src = urllib.urlopen(url)
-       dst = open(filename, "w")
-       shutil.copyfileobj(src, dst)
-       src.close()
-       dst.close()
+       try:
+               src = urllib.urlopen(url)
+               dst = open(filename, "w")
+               shutil.copyfileobj(src, dst)
+       except KeyboardInterrupt:
+               print "\nCancelled", url
+       finally:
+               src.close()
+               dst.close()
 
 def main():
        while True: