Cleaned up imports and added support for downloading magnet torrents via sources.
This commit is contained in:
@@ -1,18 +1,11 @@
|
|||||||
from base64 import b16encode, b32decode
|
from base64 import b16encode, b32decode
|
||||||
from bencode import bencode, bdecode
|
|
||||||
from couchpotato.core.downloaders.base import Downloader, StatusList
|
|
||||||
from couchpotato.core.helpers.encoding import isInt, ss
|
|
||||||
from couchpotato.core.logger import CPLog
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
from multipartpost import MultipartPostHandler
|
import traceback
|
||||||
import cookielib
|
|
||||||
import httplib
|
from bencode import bencode, bdecode
|
||||||
import json
|
from couchpotato.core.downloaders.base import Downloader, StatusList
|
||||||
import re
|
from couchpotato.core.logger import CPLog
|
||||||
import time
|
|
||||||
import urllib
|
|
||||||
import urllib2
|
|
||||||
from rtorrent import RTorrent
|
from rtorrent import RTorrent
|
||||||
|
|
||||||
|
|
||||||
@@ -45,13 +38,17 @@ class rTorrent(Downloader):
|
|||||||
log.error('Failed sending torrent, no data')
|
log.error('Failed sending torrent, no data')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# Try download magnet torrents
|
||||||
if data.get('type') == 'torrent_magnet':
|
if data.get('type') == 'torrent_magnet':
|
||||||
log.info('magnet torrents are not supported')
|
filedata = self.magnetToTorrent(data.get('url'))
|
||||||
return False
|
|
||||||
|
if filedata is False:
|
||||||
|
return False
|
||||||
|
|
||||||
|
data['type'] = 'torrent'
|
||||||
|
|
||||||
info = bdecode(filedata)["info"]
|
info = bdecode(filedata)["info"]
|
||||||
torrent_hash = sha1(bencode(info)).hexdigest().upper()
|
torrent_hash = sha1(bencode(info)).hexdigest().upper()
|
||||||
torrent_filename = self.createFileName(data, filedata, movie)
|
|
||||||
|
|
||||||
# Convert base 32 to hex
|
# Convert base 32 to hex
|
||||||
if len(torrent_hash) == 32:
|
if len(torrent_hash) == 32:
|
||||||
|
|||||||
Reference in New Issue
Block a user