Skip to content

Commit

Permalink
Make sure torrent_cache doesn't add any duplicate urls.
Browse files Browse the repository at this point in the history
Make torrentz urlrewriter populate torrent_info_hash field so that torrent_cache plugin works with it. alternate for pull:13

git-svn-id: http://svn.flexget.com/trunk@3219 3942dd89-8c5d-46d7-aeed-044bccf3e60c
gazpachoking committed Dec 18, 2012
1 parent 0c5d042 commit 080d964
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions flexget/plugins/services/torrent_cache.py
Original file line number Diff line number Diff line change
@@ -27,10 +27,11 @@ def on_task_urlrewrite(self, task, config):
elif entry.get('torrent_info_hash'):
info_hash = entry['torrent_info_hash']
if info_hash:
# Add the mirrors in random order
random.shuffle(MIRRORS)
entry.setdefault('urls', [entry['url']])
entry['urls'].extend(host + info_hash.upper() + '.torrent' for host in MIRRORS)
urls = set(host + info_hash.upper() + '.torrent' for host in MIRRORS)
# Don't add any duplicate addresses
urls -= set(entry['urls'])
entry['urls'].extend(urls)


register_plugin(TorrentCache, 'torrent_cache', api_ver=2, builtin=True)
1 change: 1 addition & 0 deletions flexget/plugins/urlrewrite_torrentz.py
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@ def url_rewritable(self, task, entry):
def url_rewrite(self, task, entry):
hash = REGEXP.match(entry['url']).group(1)
entry['url'] = 'http://zoink.it/torrent/%s.torrent' % hash.upper()
entry['torrent_info_hash'] = hash

def search(self, query, comparator=StringComparator(), config=None):
if config:

0 comments on commit 080d964

Please sign in to comment.