mirror of
https://github.com/evilhero/mylar
synced 2025-01-03 13:34:33 +00:00
FIX:(#2124) qBittorrent download directory option not being honoured for added torrents
This commit is contained in:
parent
8913ba6e61
commit
aadb1a7d9e
1 changed files with 20 additions and 8 deletions
|
@ -10,11 +10,11 @@ from lib.qbittorrent import client
|
||||||
class TorrentClient(object):
|
class TorrentClient(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.conn = None
|
self.conn = None
|
||||||
|
|
||||||
def connect(self, host, username, password):
|
def connect(self, host, username, password):
|
||||||
if self.conn is not None:
|
if self.conn is not None:
|
||||||
return self.connect
|
return self.connect
|
||||||
|
|
||||||
if not host:
|
if not host:
|
||||||
return {'status': False}
|
return {'status': False}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class TorrentClient(object):
|
||||||
logger.error('Could not connect to qBittorrent ' + host)
|
logger.error('Could not connect to qBittorrent ' + host)
|
||||||
else:
|
else:
|
||||||
return self.client
|
return self.client
|
||||||
|
|
||||||
def find_torrent(self, hash):
|
def find_torrent(self, hash):
|
||||||
logger.debug('Finding Torrent hash: ' + hash)
|
logger.debug('Finding Torrent hash: ' + hash)
|
||||||
torrent_info = self.get_torrent(hash)
|
torrent_info = self.get_torrent(hash)
|
||||||
|
@ -53,10 +53,10 @@ class TorrentClient(object):
|
||||||
|
|
||||||
|
|
||||||
def load_torrent(self, filepath):
|
def load_torrent(self, filepath):
|
||||||
|
|
||||||
if not filepath.startswith('magnet'):
|
if not filepath.startswith('magnet'):
|
||||||
logger.info('filepath to torrent file set to : ' + filepath)
|
logger.info('filepath to torrent file set to : ' + filepath)
|
||||||
|
|
||||||
if self.client._is_authenticated is True:
|
if self.client._is_authenticated is True:
|
||||||
logger.info('Checking if Torrent Exists!')
|
logger.info('Checking if Torrent Exists!')
|
||||||
|
|
||||||
|
@ -81,18 +81,30 @@ class TorrentClient(object):
|
||||||
#multiple copies of the same issues that's already downloaded
|
#multiple copies of the same issues that's already downloaded
|
||||||
else:
|
else:
|
||||||
logger.info('Torrent not added yet, trying to add it now!')
|
logger.info('Torrent not added yet, trying to add it now!')
|
||||||
|
if any([mylar.CONFIG.QBITTORRENT_FOLDER is None, mylar.CONFIG.QBITTORRENT_FOLDER == '', mylar.CONFIG.QBITTORRENT_FOLDER == 'None']):
|
||||||
|
down_dir = None
|
||||||
|
else:
|
||||||
|
down_dir = mylar.CONFIG.QBITTORRENT_FOLDER
|
||||||
|
logger.info('Forcing Download location to: %s' % down_dir)
|
||||||
|
|
||||||
if filepath.startswith('magnet'):
|
if filepath.startswith('magnet'):
|
||||||
try:
|
try:
|
||||||
tid = self.client.download_from_link(filepath, category=str(mylar.CONFIG.QBITTORRENT_LABEL))
|
if down_dir is not None:
|
||||||
|
tid = self.client.download_from_link(filepath, savepath=str(down_dir), category=str(mylar.CONFIG.QBITTORRENT_LABEL))
|
||||||
|
else:
|
||||||
|
tid = self.client.download_from_link(filepath, category=str(mylar.CONFIG.QBITTORRENT_LABEL))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug('Torrent not added')
|
logger.debug('Torrent not added')
|
||||||
return {'status': False}
|
return {'status': False}
|
||||||
else:
|
else:
|
||||||
logger.debug('Successfully submitted for add as a magnet. Verifying item is now on client.')
|
logger.debug('Successfully submitted for add as a magnet. Verifying item is now on client.')
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
torrent_content = open(filepath, 'rb')
|
torrent_content = open(filepath, 'rb')
|
||||||
tid = self.client.download_from_file(torrent_content, category=str(mylar.CONFIG.QBITTORRENT_LABEL))
|
if down_dir is not None:
|
||||||
|
tid = self.client.download_from_file(torrent_content, savepath=str(down_dir), category=str(mylar.CONFIG.QBITTORRENT_LABEL))
|
||||||
|
else:
|
||||||
|
tid = self.client.download_from_file(torrent_content, category=str(mylar.CONFIG.QBITTORRENT_LABEL))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug('Torrent not added')
|
logger.debug('Torrent not added')
|
||||||
return {'status': False}
|
return {'status': False}
|
||||||
|
|
Loading…
Reference in a new issue