Private GIT

Skip to content
Snippets Groups Projects
Commit 89426d75 authored by Ruud's avatar Ruud
Browse files

Use multiple torrent sources to convert hash. fix #802

parent 89c295b4
Branches
Tags
No related merge requests found
...@@ -5,15 +5,22 @@ from couchpotato.core.logger import CPLog ...@@ -5,15 +5,22 @@ from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin from couchpotato.core.plugins.base import Plugin
from couchpotato.environment import Env from couchpotato.environment import Env
import os import os
import random
import re import re
import traceback
log = CPLog(__name__) log = CPLog(__name__)
class Downloader(Plugin): class Downloader(Plugin):
type = [] type = []
torrent_sources = [
'http://torrage.com/torrent/%s.torrent',
'http://torrage.ws/torrent/%s.torrent',
'http://torcache.net/torrent/%s.torrent',
]
def __init__(self): def __init__(self):
addEvent('download', self.download) addEvent('download', self.download)
addEvent('download.status', self.getDownloadStatus) addEvent('download.status', self.getDownloadStatus)
...@@ -55,14 +62,17 @@ class Downloader(Plugin): ...@@ -55,14 +62,17 @@ class Downloader(Plugin):
if len(torrent_hash) == 32: if len(torrent_hash) == 32:
torrent_hash = b16encode(b32decode(torrent_hash)) torrent_hash = b16encode(b32decode(torrent_hash))
url = 'http://torrage.com/torrent/%s.torrent' % torrent_hash sources = self.torrent_sources
random.shuffle(sources)
for source in sources:
try: try:
filedata = self.urlopen(url) filedata = self.urlopen(source % torrent_hash, show_error = False)
return filedata return filedata
except: except:
log.error('Failed converting magnet url to torrent: %s, %s', (url, traceback.format_exc())) log.debug('Torrent hash "%s" wasn\'t found on: %s', (torrent_hash, source))
log.error('Failed converting magnet url to torrent: %s', (torrent_hash))
return False return False
def isDisabled(self, manual): def isDisabled(self, manual):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment