Skip to content
This repository has been archived by the owner on Sep 25, 2021. It is now read-only.

Commit

Permalink
Merge 04c5211 into 183d14d
Browse files Browse the repository at this point in the history
  • Loading branch information
sickness0666 committed Jan 31, 2016
2 parents 183d14d + 04c5211 commit c5d33f8
Show file tree
Hide file tree
Showing 7 changed files with 603 additions and 247 deletions.
34 changes: 16 additions & 18 deletions couchpotato/core/downloaders/qbittorrent_.py
Expand Up @@ -30,11 +30,8 @@ def connect(self):
url = cleanHost(self.conf('host'), protocol = True, ssl = False)

if self.conf('username') and self.conf('password'):
self.qb = QBittorrentClient(
url,
username = self.conf('username'),
password = self.conf('password')
)
self.qb = QBittorrentClient(url)
self.qb.login(username=self.conf('username'),password=self.conf('password'))
else:
self.qb = QBittorrentClient(url)

Expand All @@ -45,10 +42,7 @@ def test(self):
:return: bool
"""

if self.connect():
return True

return False
return self.qb._is_authenticated

def download(self, data = None, media = None, filedata = None):
""" Send a torrent/nzb file to the downloader
Expand Down Expand Up @@ -95,7 +89,7 @@ def download(self, data = None, media = None, filedata = None):

# Send request to qBittorrent
try:
self.qb.add_file(filedata)
self.qb.download_from_file(filedata, label=self.conf('label'))

return self.downloadReturnId(torrent_hash)
except Exception as e:
Expand Down Expand Up @@ -127,14 +121,13 @@ def getAllDownloadStatus(self, ids):
return []

try:
torrents = self.qb.get_torrents()
torrents = self.qb.torrents(label=self.conf('label'))

release_downloads = ReleaseDownloadList(self)

for torrent in torrents:
if torrent.hash in ids:
torrent.update_general() # get extra info
torrent_filelist = torrent.get_files()
torrent_filelist = self.qb.get_torrent_files(torrent.hash)

torrent_files = []
torrent_dir = os.path.join(torrent.save_path, torrent.name)
Expand Down Expand Up @@ -179,8 +172,8 @@ def pause(self, release_download, pause = True):
return False

if pause:
return torrent.pause()
return torrent.resume()
return self.qb.pause(release_download['id'])
return self.qb.resume(release_download['id'])

def removeFailed(self, release_download):
log.info('%s failed downloading, deleting...', release_download['name'])
Expand All @@ -193,15 +186,15 @@ def processComplete(self, release_download, delete_files):
if not self.connect():
return False

torrent = self.qb.find_torrent(release_download['id'])
torrent = self.qb.get_torrent(release_download['id'])

if torrent is None:
return False

if delete_files:
torrent.delete() # deletes torrent with data
self.qb.delete_permanently(release_download['id']) # deletes torrent with data
else:
torrent.remove() # just removes the torrent, doesn't delete data
self.qb.delete(release_download['id']) # just removes the torrent, doesn't delete data

return True

Expand Down Expand Up @@ -235,6 +228,11 @@ def processComplete(self, release_download, delete_files):
'name': 'password',
'type': 'password',
},
{
'name': 'label',
'label': 'Torrent Label',
'default': 'couchpotato',
},
{
'name': 'remove_complete',
'label': 'Remove torrent',
Expand Down
2 changes: 1 addition & 1 deletion libs/qbittorrent/__init__.py
@@ -1 +1 @@
__version__ = '0.1'
__version__ = '0.2'
62 changes: 0 additions & 62 deletions libs/qbittorrent/base.py

This file was deleted.

0 comments on commit c5d33f8

Please sign in to comment.