Use multiple torrent sources to convert hash. fix #802
This commit is contained in:
@@ -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):
|
|||||||
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)
|
||||||
|
|
||||||
try:
|
for source in sources:
|
||||||
filedata = self.urlopen(url)
|
try:
|
||||||
return filedata
|
filedata = self.urlopen(source % torrent_hash, show_error = False)
|
||||||
except:
|
return filedata
|
||||||
log.error('Failed converting magnet url to torrent: %s, %s', (url, traceback.format_exc()))
|
except:
|
||||||
|
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):
|
||||||
|
|||||||
Reference in New Issue
Block a user