mirror of https://github.com/evilhero/mylar
FIX: Combine qBittorrent add-paused action with the initial add-torrent to fix pauses occasionally being lost. Revise the way args are passed to the QBT add torrent method.
This commit is contained in:
parent
86ef093076
commit
a73fe47166
|
@ -85,18 +85,22 @@ 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)
|
|
||||||
|
|
||||||
|
# Build an arg dict based on user prefs.
|
||||||
|
addargs = {}
|
||||||
|
if not any([mylar.CONFIG.QBITTORRENT_LABEL is None, mylar.CONFIG.QBITTORRENT_LABEL == '', mylar.CONFIG.QBITTORRENT_LABEL == 'None']):
|
||||||
|
addargs.update( { 'category': str(mylar.CONFIG.QBITTORRENT_LABEL) } )
|
||||||
|
logger.info('Setting download label to: %s' % mylar.CONFIG.QBITTORRENT_LABEL)
|
||||||
|
if not any([mylar.CONFIG.QBITTORRENT_FOLDER is None, mylar.CONFIG.QBITTORRENT_FOLDER == '', mylar.CONFIG.QBITTORRENT_FOLDER == 'None']):
|
||||||
|
addargs.update( { 'savepath': str(mylar.CONFIG.QBITTORRENT_FOLDER) } )
|
||||||
|
logger.info('Forcing download location to: %s' % mylar.CONFIG.QBITTORRENT_FOLDER)
|
||||||
|
if mylar.CONFIG.QBITTORRENT_LOADACTION == 'pause':
|
||||||
|
addargs.update( { 'paused': 'true' } )
|
||||||
|
logger.info('Attempting to add torrent in paused state')
|
||||||
|
|
||||||
if filepath.startswith('magnet'):
|
if filepath.startswith('magnet'):
|
||||||
try:
|
try:
|
||||||
if down_dir is not None:
|
tid = self.client.download_from_link(filepath, **addargs)
|
||||||
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.error('Torrent not added')
|
logger.error('Torrent not added')
|
||||||
return {'status': False, 'error': e}
|
return {'status': False, 'error': e}
|
||||||
|
@ -105,10 +109,7 @@ class TorrentClient(object):
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
torrent_content = open(filepath, 'rb')
|
torrent_content = open(filepath, 'rb')
|
||||||
if down_dir is not None:
|
tid = self.client.download_from_file(torrent_content, **addargs)
|
||||||
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.error('Torrent not added')
|
logger.error('Torrent not added')
|
||||||
return {'status': False, 'error': e}
|
return {'status': False, 'error': e}
|
||||||
|
@ -122,13 +123,6 @@ class TorrentClient(object):
|
||||||
logger.info('startit returned: %s' % startit)
|
logger.info('startit returned: %s' % startit)
|
||||||
except:
|
except:
|
||||||
logger.warn('Unable to force start torrent - please check your client.')
|
logger.warn('Unable to force start torrent - please check your client.')
|
||||||
elif mylar.CONFIG.QBITTORRENT_LOADACTION == 'pause':
|
|
||||||
logger.info('Attempting to pause torrent after loading')
|
|
||||||
try:
|
|
||||||
startit = self.client.pause(hash)
|
|
||||||
logger.info('startit paused: %s' % startit)
|
|
||||||
except:
|
|
||||||
logger.warn('Unable to pause torrent - possibly already paused?')
|
|
||||||
else:
|
else:
|
||||||
logger.info('Client default add action selected. Doing nothing.')
|
logger.info('Client default add action selected. Doing nothing.')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue