Update of uTorrent
This commit is contained in:
@@ -6,6 +6,7 @@ from couchpotato.core.logger import CPLog
|
|||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
from multipartpost import MultipartPostHandler
|
from multipartpost import MultipartPostHandler
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
import os
|
||||||
import cookielib
|
import cookielib
|
||||||
import httplib
|
import httplib
|
||||||
import json
|
import json
|
||||||
@@ -105,6 +106,35 @@ class uTorrent(Downloader):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
statuses = StatusList(self)
|
statuses = StatusList(self)
|
||||||
|
download_folder = ''
|
||||||
|
settings_dict = {}
|
||||||
|
|
||||||
|
try:
|
||||||
|
data = self.utorrent_api.get_settings()
|
||||||
|
utorrent_settings = json.loads(data)
|
||||||
|
|
||||||
|
# Create settings dict
|
||||||
|
for item in utorrent_settings['settings']:
|
||||||
|
if item[1] == 0: # int
|
||||||
|
settings_dict[item[0]] = int(item[2] if not item[2].strip() == '' else '0')
|
||||||
|
elif item[1] == 1: # bool
|
||||||
|
settings_dict[item[0]] = True if item[2] == 'true' else False
|
||||||
|
elif item[1] == 2: # string
|
||||||
|
settings_dict[item[0]] = item[2]
|
||||||
|
log.debug('uTorrent settings: %s', settings_dict)
|
||||||
|
|
||||||
|
# Get the download path from the uTorrent settings
|
||||||
|
if settings_dict['dir_completed_download_flag']:
|
||||||
|
download_folder = settings_dict['dir_completed_download']
|
||||||
|
elif settings_dict['dir_active_download_flag']:
|
||||||
|
download_folder = settings_dict['dir_active_download']
|
||||||
|
else:
|
||||||
|
log.info('No download folder set in uTorrent. Please set a download folder')
|
||||||
|
return False
|
||||||
|
|
||||||
|
except Exception, err:
|
||||||
|
log.error('Failed to get settings from uTorrent: %s', err)
|
||||||
|
return False
|
||||||
|
|
||||||
# Get torrents
|
# Get torrents
|
||||||
for item in queue.get('torrents', []):
|
for item in queue.get('torrents', []):
|
||||||
@@ -114,13 +144,18 @@ class uTorrent(Downloader):
|
|||||||
if item[21] == 'Finished' or item[21] == 'Seeding':
|
if item[21] == 'Finished' or item[21] == 'Seeding':
|
||||||
status = 'completed'
|
status = 'completed'
|
||||||
|
|
||||||
|
if settings_dict['dir_add_label']:
|
||||||
|
release_folder = os.path.join(download_folder, item[11], item[2])
|
||||||
|
else:
|
||||||
|
release_folder = os.path.join(download_folder, item[2])
|
||||||
|
|
||||||
statuses.append({
|
statuses.append({
|
||||||
'id': item[0],
|
'id': item[0],
|
||||||
'name': item[2],
|
'name': item[2],
|
||||||
'status': status,
|
'status': status,
|
||||||
'original_status': item[1],
|
'original_status': item[1],
|
||||||
'timeleft': str(timedelta(seconds = item[10])),
|
'timeleft': str(timedelta(seconds = item[10])),
|
||||||
'folder': '', #no fucntion to get folder, but can be deduced with getSettings function.
|
'folder': release_folder,
|
||||||
})
|
})
|
||||||
|
|
||||||
return statuses
|
return statuses
|
||||||
@@ -197,3 +232,7 @@ class uTorrentAPI(object):
|
|||||||
def get_status(self):
|
def get_status(self):
|
||||||
action = "list=1"
|
action = "list=1"
|
||||||
return self._request(action)
|
return self._request(action)
|
||||||
|
|
||||||
|
def get_settings(self):
|
||||||
|
action = "action=getsettings"
|
||||||
|
return self._request(action)
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class Renamer(Plugin):
|
|||||||
self.renaming_started = True
|
self.renaming_started = True
|
||||||
|
|
||||||
# Check to see if the "to" folder is inside the "from" folder.
|
# Check to see if the "to" folder is inside the "from" folder.
|
||||||
if movie_folder and not os.path.isdir(movie_folder): # or not os.path.isdir(self.conf('from')) or not os.path.isdir(self.conf('to')):
|
if movie_folder and not os.path.isdir(movie_folder) or not os.path.isdir(self.conf('from')) or not os.path.isdir(self.conf('to')):
|
||||||
log.debug('"To" and "From" have to exist.')
|
log.debug('"To" and "From" have to exist.')
|
||||||
return
|
return
|
||||||
elif self.conf('from') in self.conf('to'):
|
elif self.conf('from') in self.conf('to'):
|
||||||
|
|||||||
Reference in New Issue
Block a user