Permalink
Browse files

Remove wget dependancy and just add .torrent to non torrent files (wo…

…rks for mininova).
  • Loading branch information...
1 parent 8d5d01c commit a691ed1bc99ba88adc92bd27b430f251f9142822 @JamieBennett committed Mar 28, 2009
Showing with 9 additions and 10 deletions.
  1. +9 −10 rsstorrent.py
View
@@ -24,9 +24,9 @@
FEEDS = [
"http://somefeedurl.com",
]
+
DOWNLOAD_DIR = "/home/jamie/downloads/torrents/"
TIMESTAMP = "/home/jamie/downloads/rsstorrent.stamp"
-WGET_OPTIONS = "--content-disposition"
VERBOSE = True
import feedparser
@@ -45,15 +45,14 @@ def download(url):
"""
remote_file = urllib2.urlopen(url)
- # See if this is a redirect to the real file. If so fall back to wget
- try:
- disposition = remote_file.info()['Content-Disposition']
- os.system('wget "%s" "%s" -P "%s"' % (url, WGET_OPTIONS, DOWNLOAD_DIR))
- except KeyError:
- local_file = open('%s%s' % (DOWNLOAD_DIR, url.split('/')[-1]), 'w')
- local_file.write(remote_file.read())
- local_file.close()
-
+ # if this isn't a torrent file (probably from mininova) add a .torrent
+ # extension
+ if url[-7:] != "torrent":
+ url += ".torrent"
+
+ local_file = open('%s%s' % (DOWNLOAD_DIR, url.split('/')[-1]), 'w')
+ local_file.write(remote_file.read())
+ local_file.close()
remote_file.close()
# Build up a list of torrents to check

0 comments on commit a691ed1

Please sign in to comment.