diff --git a/CouchPotato.py b/CouchPotato.py
index e777f9b..069fb65 100755
--- a/CouchPotato.py
+++ b/CouchPotato.py
@@ -132,14 +132,14 @@ if __name__ == '__main__':
pass
except SystemExit:
raise
- except socket.error as (nr, msg):
+ except socket.error as e:
# log when socket receives SIGINT, but continue.
# previous code would have skipped over other types of IO errors too.
if nr != 4:
try:
l.log.critical(traceback.format_exc())
except:
- print traceback.format_exc()
+ print(traceback.format_exc())
raise
except:
try:
@@ -148,7 +148,7 @@ if __name__ == '__main__':
if l:
l.log.critical(traceback.format_exc())
else:
- print traceback.format_exc()
+ print(traceback.format_exc())
except:
- print traceback.format_exc()
+ print(traceback.format_exc())
raise
diff --git a/couchpotato/__init__.py b/couchpotato/__init__.py
index b8aa3ab..b61cd84 100644
--- a/couchpotato/__init__.py
+++ b/couchpotato/__init__.py
@@ -9,13 +9,12 @@ import os
import time
import traceback
-log = CPLog(__name__)
+log = CPLog(__name__)
views = {}
template_loader = template.Loader(os.path.join(os.path.dirname(__file__), 'templates'))
-
class BaseHandler(RequestHandler):
def get_current_user(self):
@@ -24,9 +23,10 @@ class BaseHandler(RequestHandler):
if username and password:
return self.get_secure_cookie('user')
- else: # Login when no username or password are set
+ else: # Login when no username or password are set
return True
+
# Main web handler
class WebHandler(BaseHandler):
@@ -43,9 +43,11 @@ class WebHandler(BaseHandler):
log.error("Failed doing web request '%s': %s", (route, traceback.format_exc()))
self.write({'success': False, 'error': 'Failed returning results'})
+
def addView(route, func, static = False):
views[route] = func
+
def get_session(engine = None):
return Env.getSession(engine)
@@ -55,6 +57,7 @@ def index():
return template_loader.load('index.html').generate(sep = os.sep, fireEvent = fireEvent, Env = Env)
addView('', index)
+
# API docs
def apiDocs():
routes = []
@@ -70,21 +73,22 @@ def apiDocs():
addView('docs', apiDocs)
+
# Make non basic auth option to get api key
class KeyHandler(RequestHandler):
def get(self, *args, **kwargs):
- api = None
+ api_key = None
try:
username = Env.setting('username')
password = Env.setting('password')
if (self.get_argument('u') == md5(username) or not username) and (self.get_argument('p') == password or not password):
- api = Env.setting('api_key')
+ api_key = Env.setting('api_key')
self.write({
- 'success': api is not None,
- 'api_key': api
+ 'success': api_key is not None,
+ 'api_key': api_key
})
except:
log.error('Failed doing key request: %s', (traceback.format_exc()))
@@ -102,20 +106,21 @@ class LoginHandler(BaseHandler):
def post(self, *args, **kwargs):
- api = None
+ api_key = None
username = Env.setting('username')
password = Env.setting('password')
if (self.get_argument('username') == username or not username) and (md5(self.get_argument('password')) == password or not password):
- api = Env.setting('api_key')
+ api_key = Env.setting('api_key')
- if api:
+ if api_key:
remember_me = tryInt(self.get_argument('remember_me', default = 0))
- self.set_secure_cookie('user', api, expires_days = 30 if remember_me > 0 else None)
+ self.set_secure_cookie('user', api_key, expires_days = 30 if remember_me > 0 else None)
self.redirect(Env.get('web_base'))
+
class LogoutHandler(BaseHandler):
def get(self, *args, **kwargs):
@@ -136,4 +141,3 @@ def page_not_found(rh):
rh.set_status(404)
rh.write('Wrong API key used')
-
diff --git a/couchpotato/api.py b/couchpotato/api.py
index e86b127..ba7f7b6 100644
--- a/couchpotato/api.py
+++ b/couchpotato/api.py
@@ -20,6 +20,7 @@ api_nonblock = {}
api_docs = {}
api_docs_missing = []
+
def run_async(func):
@wraps(func)
def async_func(*args, **kwargs):
@@ -29,6 +30,7 @@ def run_async(func):
return async_func
+
# NonBlock API handler
class NonBlockHandler(RequestHandler):
@@ -61,6 +63,7 @@ class NonBlockHandler(RequestHandler):
self.stopper = None
+
def addNonBlockApiView(route, func_tuple, docs = None, **kwargs):
api_nonblock[route] = func_tuple
@@ -69,6 +72,7 @@ def addNonBlockApiView(route, func_tuple, docs = None, **kwargs):
else:
api_docs_missing.append(route)
+
# Blocking API handler
class ApiHandler(RequestHandler):
@@ -98,11 +102,12 @@ class ApiHandler(RequestHandler):
@run_async
def run_handler(callback):
try:
- result = api[route](**kwargs)
- callback(result)
+ res = api[route](**kwargs)
+ callback(res)
except:
log.error('Failed doing api request "%s": %s', (route, traceback.format_exc()))
callback({'success': False, 'error': 'Failed returning results'})
+
result = yield tornado.gen.Task(run_handler)
# Check JSONP callback
@@ -122,6 +127,7 @@ class ApiHandler(RequestHandler):
api_locks[route].release()
+
def addApiView(route, func, static = False, docs = None, **kwargs):
if static: func(route)
diff --git a/couchpotato/core/_base/_core/__init__.py b/couchpotato/core/_base/_core/__init__.py
index 4d1a684..58965bb 100644
--- a/couchpotato/core/_base/_core/__init__.py
+++ b/couchpotato/core/_base/_core/__init__.py
@@ -1,6 +1,7 @@
from .main import Core
from uuid import uuid4
+
def start():
return Core()
diff --git a/couchpotato/core/_base/_core/main.py b/couchpotato/core/_base/_core/main.py
index f2435eb..02e21f2 100644
--- a/couchpotato/core/_base/_core/main.py
+++ b/couchpotato/core/_base/_core/main.py
@@ -117,7 +117,7 @@ class Core(Plugin):
if len(still_running) == 0:
break
- elif starttime < time.time() - 30: # Always force break after 30s wait
+ elif starttime < time.time() - 30: # Always force break after 30s wait
break
running = list(set(still_running) - set(self.ignore_restart))
diff --git a/couchpotato/core/_base/clientscript/__init__.py b/couchpotato/core/_base/clientscript/__init__.py
index 8490eae..8070044 100644
--- a/couchpotato/core/_base/clientscript/__init__.py
+++ b/couchpotato/core/_base/clientscript/__init__.py
@@ -1,5 +1,6 @@
from .main import ClientScript
+
def start():
return ClientScript()
diff --git a/couchpotato/core/_base/clientscript/main.py b/couchpotato/core/_base/clientscript/main.py
index b80ddcc..248d2bc 100644
--- a/couchpotato/core/_base/clientscript/main.py
+++ b/couchpotato/core/_base/clientscript/main.py
@@ -53,9 +53,9 @@ class ClientScript(Plugin):
}
- urls = {'style': {}, 'script': {}, }
- minified = {'style': {}, 'script': {}, }
- paths = {'style': {}, 'script': {}, }
+ urls = {'style': {}, 'script': {}}
+ minified = {'style': {}, 'script': {}}
+ paths = {'style': {}, 'script': {}}
comment = {
'style': '/*** %s:%d ***/\n',
'script': '// %s:%d\n'
diff --git a/couchpotato/core/_base/desktop/__init__.py b/couchpotato/core/_base/desktop/__init__.py
index 064492f..e59ca52 100644
--- a/couchpotato/core/_base/desktop/__init__.py
+++ b/couchpotato/core/_base/desktop/__init__.py
@@ -1,5 +1,6 @@
from .main import Desktop
+
def start():
return Desktop()
diff --git a/couchpotato/core/_base/scheduler/__init__.py b/couchpotato/core/_base/scheduler/__init__.py
index aa1c5c9..abfc230 100644
--- a/couchpotato/core/_base/scheduler/__init__.py
+++ b/couchpotato/core/_base/scheduler/__init__.py
@@ -1,5 +1,6 @@
from .main import Scheduler
+
def start():
return Scheduler()
diff --git a/couchpotato/core/_base/updater/__init__.py b/couchpotato/core/_base/updater/__init__.py
index a304f9e..7ad30d2 100644
--- a/couchpotato/core/_base/updater/__init__.py
+++ b/couchpotato/core/_base/updater/__init__.py
@@ -2,6 +2,7 @@ from .main import Updater
from couchpotato.environment import Env
import os
+
def start():
return Updater()
diff --git a/couchpotato/core/_base/updater/main.py b/couchpotato/core/_base/updater/main.py
index 8dc7893..22668d9 100644
--- a/couchpotato/core/_base/updater/main.py
+++ b/couchpotato/core/_base/updater/main.py
@@ -63,7 +63,7 @@ class Updater(Plugin):
fireEvent('schedule.remove', 'updater.check', single = True)
if self.isEnabled():
fireEvent('schedule.interval', 'updater.check', self.autoUpdate, hours = 6)
- self.autoUpdate() # Check after enabling
+ self.autoUpdate() # Check after enabling
def autoUpdate(self):
if self.isEnabled() and self.check() and self.conf('automatic') and not self.updater.update_failed:
@@ -151,6 +151,9 @@ class BaseUpdater(Plugin):
'branch': self.branch,
}
+ def getVersion(self):
+ pass
+
def check(self):
pass
@@ -179,7 +182,6 @@ class BaseUpdater(Plugin):
log.error('Couldn\'t remove empty directory %s: %s', (full_path, traceback.format_exc()))
-
class GitUpdater(BaseUpdater):
def __init__(self, git_command):
@@ -206,7 +208,7 @@ class GitUpdater(BaseUpdater):
if not self.version:
try:
- output = self.repo.getHead() # Yes, please
+ output = self.repo.getHead() # Yes, please
log.debug('Git version output: %s', output.hash)
self.version = {
'repr': 'git:(%s:%s % s) %s (%s)' % (self.repo_user, self.repo_name, self.branch, output.hash[:8], datetime.fromtimestamp(output.getDate())),
@@ -214,7 +216,7 @@ class GitUpdater(BaseUpdater):
'date': output.getDate(),
'type': 'git',
}
- except Exception, e:
+ except Exception as e:
log.error('Failed using GIT updater, running from source, you need to have GIT installed. %s', e)
return 'No GIT'
@@ -250,7 +252,6 @@ class GitUpdater(BaseUpdater):
return False
-
class SourceUpdater(BaseUpdater):
def __init__(self):
@@ -276,9 +277,9 @@ class SourceUpdater(BaseUpdater):
# Extract
if download_data.get('type') == 'zip':
- zip = zipfile.ZipFile(destination)
- zip.extractall(extracted_path)
- zip.close()
+ zip_file = zipfile.ZipFile(destination)
+ zip_file.extractall(extracted_path)
+ zip_file.close()
else:
tar = tarfile.open(destination)
tar.extractall(path = extracted_path)
@@ -345,7 +346,6 @@ class SourceUpdater(BaseUpdater):
return True
-
def removeDir(self, path):
try:
if os.path.isdir(path):
@@ -366,7 +366,7 @@ class SourceUpdater(BaseUpdater):
self.version = output
self.version['type'] = 'source'
self.version['repr'] = 'source:(%s:%s % s) %s (%s)' % (self.repo_user, self.repo_name, self.branch, output.get('hash', '')[:8], datetime.fromtimestamp(output.get('date', 0)))
- except Exception, e:
+ except Exception as e:
log.error('Failed using source updater. %s', e)
return {}
@@ -396,7 +396,7 @@ class SourceUpdater(BaseUpdater):
return {
'hash': commit['sha'],
- 'date': int(time.mktime(parse(commit['commit']['committer']['date']).timetuple())),
+ 'date': int(time.mktime(parse(commit['commit']['committer']['date']).timetuple())),
}
except:
log.error('Failed getting latest request from github: %s', traceback.format_exc())
@@ -441,7 +441,7 @@ class DesktopUpdater(BaseUpdater):
if latest and latest != current_version.get('hash'):
self.update_version = {
'hash': latest,
- 'date': None,
+ 'date': None,
'changelog': self.desktop._changelogURL,
}
diff --git a/couchpotato/core/downloaders/blackhole/__init__.py b/couchpotato/core/downloaders/blackhole/__init__.py
index 91164d6..92d18e7 100644
--- a/couchpotato/core/downloaders/blackhole/__init__.py
+++ b/couchpotato/core/downloaders/blackhole/__init__.py
@@ -1,6 +1,7 @@
from .main import Blackhole
from couchpotato.core.helpers.variable import getDownloadDir
+
def start():
return Blackhole()
diff --git a/couchpotato/core/downloaders/deluge/__init__.py b/couchpotato/core/downloaders/deluge/__init__.py
index c7aa26e..09fae75 100644
--- a/couchpotato/core/downloaders/deluge/__init__.py
+++ b/couchpotato/core/downloaders/deluge/__init__.py
@@ -1,5 +1,6 @@
from .main import Deluge
+
def start():
return Deluge()
diff --git a/couchpotato/core/downloaders/deluge/main.py b/couchpotato/core/downloaders/deluge/main.py
index 2d9084b..53b87d9 100644
--- a/couchpotato/core/downloaders/deluge/main.py
+++ b/couchpotato/core/downloaders/deluge/main.py
@@ -109,7 +109,7 @@ class Deluge(Downloader):
continue
log.debug('name=%s / id=%s / save_path=%s / move_on_completed=%s / move_completed_path=%s / hash=%s / progress=%s / state=%s / eta=%s / ratio=%s / stop_ratio=%s / is_seed=%s / is_finished=%s / paused=%s', (torrent['name'], torrent['hash'], torrent['save_path'], torrent['move_on_completed'], torrent['move_completed_path'], torrent['hash'], torrent['progress'], torrent['state'], torrent['eta'], torrent['ratio'], torrent['stop_ratio'], torrent['is_seed'], torrent['is_finished'], torrent['paused']))
-
+
# Deluge has no easy way to work out if a torrent is stalled or failing.
#status = 'failed'
status = 'busy'
@@ -125,11 +125,11 @@ class Deluge(Downloader):
download_dir = sp(torrent['save_path'])
if torrent['move_on_completed']:
download_dir = torrent['move_completed_path']
-
+
torrent_files = []
for file_item in torrent['files']:
torrent_files.append(sp(os.path.join(download_dir, file_item['path'])))
-
+
release_downloads.append({
'id': torrent['hash'],
'name': torrent['name'],
@@ -157,6 +157,7 @@ class Deluge(Downloader):
log.debug('Requesting Deluge to remove the torrent %s%s.', (release_download['name'], ' and cleanup the downloaded files' if delete_files else ''))
return self.drpc.remove_torrent(release_download['id'], remove_local_data = delete_files)
+
class DelugeRPC(object):
host = 'localhost'
diff --git a/couchpotato/core/downloaders/nzbget/__init__.py b/couchpotato/core/downloaders/nzbget/__init__.py
index 1f21c05..551eb42 100644
--- a/couchpotato/core/downloaders/nzbget/__init__.py
+++ b/couchpotato/core/downloaders/nzbget/__init__.py
@@ -1,5 +1,6 @@
from .main import NZBGet
+
def start():
return NZBGet()
diff --git a/couchpotato/core/downloaders/nzbget/main.py b/couchpotato/core/downloaders/nzbget/main.py
index a05fb11..a690572 100644
--- a/couchpotato/core/downloaders/nzbget/main.py
+++ b/couchpotato/core/downloaders/nzbget/main.py
@@ -42,7 +42,7 @@ class NZBGet(Downloader):
except socket.error:
log.error('NZBGet is not responding. Please ensure that NZBGet is running and host setting is correct.')
return False
- except xmlrpclib.ProtocolError, e:
+ except xmlrpclib.ProtocolError as e:
if e.errcode == 401:
log.error('Password is incorrect.')
else:
@@ -56,7 +56,7 @@ class NZBGet(Downloader):
if xml_response:
log.info('NZB sent successfully to NZBGet')
- nzb_id = md5(data['url']) # about as unique as they come ;)
+ nzb_id = md5(data['url']) # about as unique as they come ;)
couchpotato_id = "couchpotato=" + nzb_id
groups = rpc.listgroups()
file_id = [item['LastID'] for item in groups if item['NZBFilename'] == nzb_name]
@@ -83,7 +83,7 @@ class NZBGet(Downloader):
except socket.error:
log.error('NZBGet is not responding. Please ensure that NZBGet is running and host setting is correct.')
return []
- except xmlrpclib.ProtocolError, e:
+ except xmlrpclib.ProtocolError as e:
if e.errcode == 401:
log.error('Password is incorrect.')
else:
@@ -116,7 +116,7 @@ class NZBGet(Downloader):
timeleft = str(timedelta(seconds = nzb['RemainingSizeMB'] / status['DownloadRate'] * 2 ^ 20))
except:
pass
-
+
release_downloads.append({
'id': nzb_id,
'name': nzb['NZBFilename'],
@@ -169,7 +169,7 @@ class NZBGet(Downloader):
except socket.error:
log.error('NZBGet is not responding. Please ensure that NZBGet is running and host setting is correct.')
return False
- except xmlrpclib.ProtocolError, e:
+ except xmlrpclib.ProtocolError as e:
if e.errcode == 401:
log.error('Password is incorrect.')
else:
diff --git a/couchpotato/core/downloaders/nzbvortex/__init__.py b/couchpotato/core/downloaders/nzbvortex/__init__.py
index 3087d75..1c2d699 100644
--- a/couchpotato/core/downloaders/nzbvortex/__init__.py
+++ b/couchpotato/core/downloaders/nzbvortex/__init__.py
@@ -1,5 +1,6 @@
from .main import NZBVortex
+
def start():
return NZBVortex()
diff --git a/couchpotato/core/downloaders/nzbvortex/main.py b/couchpotato/core/downloaders/nzbvortex/main.py
index d2615bf..205ceb1 100644
--- a/couchpotato/core/downloaders/nzbvortex/main.py
+++ b/couchpotato/core/downloaders/nzbvortex/main.py
@@ -56,13 +56,13 @@ class NZBVortex(Downloader):
status = 'completed'
elif nzb['state'] in [21, 22, 24]:
status = 'failed'
-
+
release_downloads.append({
'id': nzb['id'],
'name': nzb['uiTitle'],
'status': status,
'original_status': nzb['state'],
- 'timeleft':-1,
+ 'timeleft': -1,
'folder': sp(nzb['destinationPath']),
})
@@ -102,7 +102,6 @@ class NZBVortex(Downloader):
log.error('Login failed, please check you api-key')
return False
-
def call(self, call, parameters = None, repeat = False, auth = True, *args, **kwargs):
# Login first
@@ -123,7 +122,7 @@ class NZBVortex(Downloader):
if data:
return json.loads(data)
- except URLError, e:
+ except URLError as e:
if hasattr(e, 'code') and e.code == 403:
# Try login and do again
if not repeat:
@@ -145,7 +144,7 @@ class NZBVortex(Downloader):
try:
data = self.urlopen(url, show_error = False)
self.api_level = float(json.loads(data).get('apilevel'))
- except URLError, e:
+ except URLError as e:
if hasattr(e, 'code') and e.code == 403:
log.error('This version of NZBVortex isn\'t supported. Please update to 2.8.6 or higher')
else:
@@ -175,6 +174,7 @@ class HTTPSConnection(httplib.HTTPSConnection):
self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file, ssl_version = ssl.PROTOCOL_TLSv1)
+
class HTTPSHandler(urllib2.HTTPSHandler):
def https_open(self, req):
return self.do_open(HTTPSConnection, req)
diff --git a/couchpotato/core/downloaders/pneumatic/__init__.py b/couchpotato/core/downloaders/pneumatic/__init__.py
index 96574a7..698643f 100644
--- a/couchpotato/core/downloaders/pneumatic/__init__.py
+++ b/couchpotato/core/downloaders/pneumatic/__init__.py
@@ -1,5 +1,6 @@
from .main import Pneumatic
+
def start():
return Pneumatic()
diff --git a/couchpotato/core/downloaders/pneumatic/main.py b/couchpotato/core/downloaders/pneumatic/main.py
index d3fdad8..6af22d2 100644
--- a/couchpotato/core/downloaders/pneumatic/main.py
+++ b/couchpotato/core/downloaders/pneumatic/main.py
@@ -26,26 +26,26 @@ class Pneumatic(Downloader):
log.error('No nzb available!')
return False
- fullPath = os.path.join(directory, self.createFileName(data, filedata, media))
+ full_path = os.path.join(directory, self.createFileName(data, filedata, media))
try:
- if not os.path.isfile(fullPath):
- log.info('Downloading %s to %s.', (data.get('protocol'), fullPath))
- with open(fullPath, 'wb') as f:
+ if not os.path.isfile(full_path):
+ log.info('Downloading %s to %s.', (data.get('protocol'), full_path))
+ with open(full_path, 'wb') as f:
f.write(filedata)
nzb_name = self.createNzbName(data, media)
strm_path = os.path.join(directory, nzb_name)
strm_file = open(strm_path + '.strm', 'wb')
- strmContent = self.strm_syntax % (fullPath, nzb_name)
+ strmContent = self.strm_syntax % (full_path, nzb_name)
strm_file.write(strmContent)
strm_file.close()
return self.downloadReturnId('')
else:
- log.info('File %s already exists.', fullPath)
+ log.info('File %s already exists.', full_path)
return self.downloadReturnId('')
except:
diff --git a/couchpotato/core/downloaders/rtorrent/__init__.py b/couchpotato/core/downloaders/rtorrent/__init__.py
index dbef6e6..4a593fd 100755
--- a/couchpotato/core/downloaders/rtorrent/__init__.py
+++ b/couchpotato/core/downloaders/rtorrent/__init__.py
@@ -1,5 +1,6 @@
from .main import rTorrent
+
def start():
return rTorrent()
diff --git a/couchpotato/core/downloaders/rtorrent/main.py b/couchpotato/core/downloaders/rtorrent/main.py
index 5027631..e8794ec 100755
--- a/couchpotato/core/downloaders/rtorrent/main.py
+++ b/couchpotato/core/downloaders/rtorrent/main.py
@@ -111,7 +111,6 @@ class rTorrent(Downloader):
if self.conf('label'):
torrent_params['label'] = self.conf('label')
-
if not filedata and data.get('protocol') == 'torrent':
log.error('Failed sending torrent, no data')
return False
diff --git a/couchpotato/core/downloaders/sabnzbd/__init__.py b/couchpotato/core/downloaders/sabnzbd/__init__.py
index 1edbbeb..2990078 100644
--- a/couchpotato/core/downloaders/sabnzbd/__init__.py
+++ b/couchpotato/core/downloaders/sabnzbd/__init__.py
@@ -1,5 +1,6 @@
from .main import Sabnzbd
+
def start():
return Sabnzbd()
diff --git a/couchpotato/core/downloaders/sabnzbd/main.py b/couchpotato/core/downloaders/sabnzbd/main.py
index 1d9073f..72c2370 100644
--- a/couchpotato/core/downloaders/sabnzbd/main.py
+++ b/couchpotato/core/downloaders/sabnzbd/main.py
@@ -95,7 +95,7 @@ class Sabnzbd(Downloader):
status = 'busy'
if 'ENCRYPTED / ' in nzb['filename']:
status = 'failed'
-
+
release_downloads.append({
'id': nzb['nzo_id'],
'name': nzb['filename'],
@@ -112,7 +112,7 @@ class Sabnzbd(Downloader):
status = 'failed'
elif nzb['status'] == 'Completed':
status = 'completed'
-
+
release_downloads.append({
'id': nzb['nzo_id'],
'name': nzb['name'],
@@ -166,8 +166,8 @@ class Sabnzbd(Downloader):
def call(self, request_params, use_json = True, **kwargs):
url = cleanHost(self.conf('host'), ssl = self.conf('ssl')) + 'api?' + tryUrlencode(mergeDicts(request_params, {
- 'apikey': self.conf('api_key'),
- 'output': 'json'
+ 'apikey': self.conf('api_key'),
+ 'output': 'json'
}))
data = self.urlopen(url, timeout = 60, show_error = False, headers = {'User-Agent': Env.getIdentifier()}, **kwargs)
diff --git a/couchpotato/core/downloaders/synology/__init__.py b/couchpotato/core/downloaders/synology/__init__.py
index 8be16f6..d0c57c2 100644
--- a/couchpotato/core/downloaders/synology/__init__.py
+++ b/couchpotato/core/downloaders/synology/__init__.py
@@ -1,5 +1,6 @@
from .main import Synology
+
def start():
return Synology()
diff --git a/couchpotato/core/downloaders/synology/main.py b/couchpotato/core/downloaders/synology/main.py
index 7299fa8..26a4558 100644
--- a/couchpotato/core/downloaders/synology/main.py
+++ b/couchpotato/core/downloaders/synology/main.py
@@ -65,6 +65,7 @@ class Synology(Downloader):
return super(Synology, self).isEnabled(manual, data) and\
((self.conf('use_for') in for_protocol))
+
class SynologyRPC(object):
"""SynologyRPC lite library"""
diff --git a/couchpotato/core/downloaders/transmission/__init__.py b/couchpotato/core/downloaders/transmission/__init__.py
index f96e628..4c9b4aa 100644
--- a/couchpotato/core/downloaders/transmission/__init__.py
+++ b/couchpotato/core/downloaders/transmission/__init__.py
@@ -1,5 +1,6 @@
from .main import Transmission
+
def start():
return Transmission()
diff --git a/couchpotato/core/downloaders/transmission/main.py b/couchpotato/core/downloaders/transmission/main.py
index d41337f..d3f1759 100644
--- a/couchpotato/core/downloaders/transmission/main.py
+++ b/couchpotato/core/downloaders/transmission/main.py
@@ -105,7 +105,7 @@ class Transmission(Downloader):
for torrent in queue['torrents']:
if torrent['hashString'] in ids:
log.debug('name=%s / id=%s / downloadDir=%s / hashString=%s / percentDone=%s / status=%s / isStalled=%s / eta=%s / uploadRatio=%s / isFinished=%s / incomplete-dir-enabled=%s / incomplete-dir=%s',
- (torrent['name'], torrent['id'], torrent['downloadDir'], torrent['hashString'], torrent['percentDone'], torrent['status'], torrent.get('isStalled', 'N/A'), torrent['eta'], torrent['uploadRatio'], torrent['isFinished'], session['incomplete-dir-enabled'], session['incomplete-dir']))
+ (torrent['name'], torrent['id'], torrent['downloadDir'], torrent['hashString'], torrent['percentDone'], torrent['status'], torrent.get('isStalled', 'N/A'), torrent['eta'], torrent['uploadRatio'], torrent['isFinished'], session['incomplete-dir-enabled'], session['incomplete-dir']))
status = 'busy'
if torrent.get('isStalled') and not torrent['percentDone'] == 1 and self.conf('stalled_as_failed'):
diff --git a/couchpotato/core/downloaders/utorrent/__init__.py b/couchpotato/core/downloaders/utorrent/__init__.py
index d45e2e6..77bd1cd 100644
--- a/couchpotato/core/downloaders/utorrent/__init__.py
+++ b/couchpotato/core/downloaders/utorrent/__init__.py
@@ -1,5 +1,6 @@
from .main import uTorrent
+
def start():
return uTorrent()
diff --git a/couchpotato/core/downloaders/utorrent/main.py b/couchpotato/core/downloaders/utorrent/main.py
index 89f75cc..e527230 100644
--- a/couchpotato/core/downloaders/utorrent/main.py
+++ b/couchpotato/core/downloaders/utorrent/main.py
@@ -66,7 +66,7 @@ class uTorrent(Downloader):
new_settings['seed_prio_limitul_flag'] = True
log.info('Updated uTorrent settings to set a torrent to complete after it the seeding requirements are met.')
- if settings.get('bt.read_only_on_complete'): #This doesn't work as this option seems to be not available through the api. Mitigated with removeReadOnly function
+ if settings.get('bt.read_only_on_complete'): #This doesn't work as this option seems to be not available through the api. Mitigated with removeReadOnly function
new_settings['bt.read_only_on_complete'] = False
log.info('Updated uTorrent settings to not set the files to read only after completing.')
@@ -149,7 +149,7 @@ class uTorrent(Downloader):
torrent_files = [sp(os.path.join(torrent[26], torrent_file[0])) for torrent_file in torrent_files['files'][1]]
except:
log.debug('Failed getting files from torrent: %s', torrent[2])
-
+
status = 'busy'
if (torrent[1] & self.status_flags['STARTED'] or torrent[1] & self.status_flags['QUEUED']) and torrent[4] == 1000:
status = 'seeding'
@@ -157,10 +157,10 @@ class uTorrent(Downloader):
status = 'failed'
elif torrent[4] == 1000:
status = 'completed'
-
+
if not status == 'busy':
self.removeReadOnly(torrent_files)
-
+
release_downloads.append({
'id': torrent[0],
'name': torrent[2],
diff --git a/couchpotato/core/event.py b/couchpotato/core/event.py
index 7b01fbd..88df65c 100644
--- a/couchpotato/core/event.py
+++ b/couchpotato/core/event.py
@@ -7,6 +7,7 @@ import traceback
log = CPLog(__name__)
events = {}
+
def runHandler(name, handler, *args, **kwargs):
try:
return handler(*args, **kwargs)
@@ -14,6 +15,7 @@ def runHandler(name, handler, *args, **kwargs):
from couchpotato.environment import Env
log.error('Error in event "%s", that wasn\'t caught: %s%s', (name, traceback.format_exc(), Env.all() if not Env.get('dev') else ''))
+
def addEvent(name, handler, priority = 100):
if not events.get(name):
@@ -48,22 +50,24 @@ def addEvent(name, handler, priority = 100):
'priority': priority,
})
+
def removeEvent(name, handler):
e = events[name]
e -= handler
+
def fireEvent(name, *args, **kwargs):
- if not events.has_key(name): return
+ if name not in events: return
#log.debug('Firing event %s', name)
try:
options = {
- 'is_after_event': False, # Fire after event
- 'on_complete': False, # onComplete event
- 'single': False, # Return single handler
- 'merge': False, # Merge items
- 'in_order': False, # Fire them in specific order, waits for the other to finish
+ 'is_after_event': False, # Fire after event
+ 'on_complete': False, # onComplete event
+ 'single': False, # Return single handler
+ 'merge': False, # Merge items
+ 'in_order': False, # Fire them in specific order, waits for the other to finish
}
# Do options
@@ -101,11 +105,14 @@ def fireEvent(name, *args, **kwargs):
# Fire
result = e(*args, **kwargs)
+ result_keys = result.keys()
+ result_keys.sort(natcmp)
+
if options['single'] and not options['merge']:
results = None
# Loop over results, stop when first not None result is found.
- for r_key in sorted(result.iterkeys(), cmp = natcmp):
+ for r_key in result_keys:
r = result[r_key]
if r[0] is True and r[1] is not None:
results = r[1]
@@ -117,7 +124,7 @@ def fireEvent(name, *args, **kwargs):
else:
results = []
- for r_key in sorted(result.iterkeys(), cmp = natcmp):
+ for r_key in result_keys:
r = result[r_key]
if r[0] == True and r[1]:
results.append(r[1])
@@ -160,18 +167,21 @@ def fireEvent(name, *args, **kwargs):
except Exception:
log.error('%s: %s', (name, traceback.format_exc()))
+
def fireEventAsync(*args, **kwargs):
try:
t = threading.Thread(target = fireEvent, args = args, kwargs = kwargs)
t.setDaemon(True)
t.start()
return True
- except Exception, e:
+ except Exception as e:
log.error('%s: %s', (args[0], e))
+
def errorHandler(error):
etype, value, tb = error
log.error(''.join(traceback.format_exception(etype, value, tb)))
+
def getEvent(name):
return events[name]
diff --git a/couchpotato/core/helpers/encoding.py b/couchpotato/core/helpers/encoding.py
index fc7c919..1c41841 100644
--- a/couchpotato/core/helpers/encoding.py
+++ b/couchpotato/core/helpers/encoding.py
@@ -11,16 +11,18 @@ log = CPLog(__name__)
def toSafeString(original):
valid_chars = "-_.() %s%s" % (ascii_letters, digits)
- cleanedFilename = unicodedata.normalize('NFKD', toUnicode(original)).encode('ASCII', 'ignore')
- valid_string = ''.join(c for c in cleanedFilename if c in valid_chars)
+ cleaned_filename = unicodedata.normalize('NFKD', toUnicode(original)).encode('ASCII', 'ignore')
+ valid_string = ''.join(c for c in cleaned_filename if c in valid_chars)
return ' '.join(valid_string.split())
+
def simplifyString(original):
string = stripAccents(original.lower())
string = toSafeString(' '.join(re.split('\W+', string)))
split = re.split('\W+|_', string.lower())
return toUnicode(' '.join(split))
+
def toUnicode(original, *args):
try:
if isinstance(original, unicode):
@@ -38,16 +40,18 @@ def toUnicode(original, *args):
ascii_text = str(original).encode('string_escape')
return toUnicode(ascii_text)
+
def ss(original, *args):
u_original = toUnicode(original, *args)
try:
from couchpotato.environment import Env
return u_original.encode(Env.get('encoding'))
- except Exception, e:
+ except Exception as e:
log.debug('Failed ss encoding char, force UTF8: %s', e)
return u_original.encode('UTF-8')
+
def sp(path, *args):
# Standardise encoding, normalise case, path and strip trailing '/' or '\'
@@ -73,6 +77,7 @@ def sp(path, *args):
return path
+
def ek(original, *args):
if isinstance(original, (str, unicode)):
try:
@@ -83,6 +88,7 @@ def ek(original, *args):
return original
+
def isInt(value):
try:
int(value)
@@ -90,9 +96,11 @@ def isInt(value):
except ValueError:
return False
+
def stripAccents(s):
return ''.join((c for c in unicodedata.normalize('NFD', toUnicode(s)) if unicodedata.category(c) != 'Mn'))
+
def tryUrlencode(s):
new = u''
if isinstance(s, dict):
diff --git a/couchpotato/core/helpers/request.py b/couchpotato/core/helpers/request.py
index 888e63f..fb91f45 100644
--- a/couchpotato/core/helpers/request.py
+++ b/couchpotato/core/helpers/request.py
@@ -37,6 +37,7 @@ def getParams(params):
return dictToList(temp)
+
def dictToList(params):
if type(params) is dict:
diff --git a/couchpotato/core/helpers/rss.py b/couchpotato/core/helpers/rss.py
index b840d86..1a4d37c 100644
--- a/couchpotato/core/helpers/rss.py
+++ b/couchpotato/core/helpers/rss.py
@@ -3,6 +3,7 @@ import xml.etree.ElementTree as XMLTree
log = CPLog(__name__)
+
class RSS(object):
def getTextElements(self, xml, path):
@@ -46,6 +47,6 @@ class RSS(object):
def getItems(self, data, path = 'channel/item'):
try:
return XMLTree.parse(data).findall(path)
- except Exception, e:
+ except Exception as e:
log.error('Error parsing RSS. %s', e)
return []
diff --git a/couchpotato/core/helpers/variable.py b/couchpotato/core/helpers/variable.py
index 658ea8c..b191d0a 100644
--- a/couchpotato/core/helpers/variable.py
+++ b/couchpotato/core/helpers/variable.py
@@ -11,8 +11,10 @@ import sys
log = CPLog(__name__)
+
def fnEscape(pattern):
- return pattern.replace('[','[[').replace(']','[]]').replace('[[','[[]')
+ return pattern.replace('[', '[[').replace(']', '[]]').replace('[[', '[[]')
+
def link(src, dst):
if os.name == 'nt':
@@ -21,6 +23,7 @@ def link(src, dst):
else:
os.link(src, dst)
+
def symlink(src, dst):
if os.name == 'nt':
import ctypes
@@ -28,6 +31,7 @@ def symlink(src, dst):
else:
os.symlink(src, dst)
+
def getUserDir():
try:
import pwd
@@ -37,6 +41,7 @@ def getUserDir():
return os.path.expanduser('~')
+
def getDownloadDir():
user_dir = getUserDir()
@@ -49,6 +54,7 @@ def getDownloadDir():
return user_dir
+
def getDataDir():
# Windows
@@ -68,8 +74,10 @@ def getDataDir():
# Linux
return os.path.join(user_dir, '.couchpotato')
-def isDict(object):
- return isinstance(object, dict)
+
+def isDict(obj):
+ return isinstance(obj, dict)
+
def mergeDicts(a, b, prepend_list = False):
assert isDict(a), isDict(b)
@@ -91,6 +99,7 @@ def mergeDicts(a, b, prepend_list = False):
current_dst[key] = current_src[key]
return dst
+
def removeListDuplicates(seq):
checked = []
for e in seq:
@@ -98,26 +107,32 @@ def removeListDuplicates(seq):
checked.append(e)
return checked
+
def flattenList(l):
if isinstance(l, list):
return sum(map(flattenList, l))
else:
return l
+
def md5(text):
return hashlib.md5(ss(text)).hexdigest()
+
def sha1(text):
return hashlib.sha1(text).hexdigest()
+
def isLocalIP(ip):
ip = ip.lstrip('htps:/')
regex = '/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1)$/'
return re.search(regex, ip) is not None or 'localhost' in ip or ip[:4] == '127.'
+
def getExt(filename):
return os.path.splitext(filename)[1][1:]
+
def cleanHost(host, protocol = True, ssl = False, username = None, password = None):
if not '://' in host and protocol:
@@ -129,7 +144,7 @@ def cleanHost(host, protocol = True, ssl = False, username = None, password = No
if protocol and username and password:
login = '%s:%s@' % (username, password)
if not login in host:
- host = host.replace('://', '://' + login, 1)
+ host = host.replace('://', '://' + login, 1)
host = host.rstrip('/ ')
if protocol:
@@ -137,6 +152,7 @@ def cleanHost(host, protocol = True, ssl = False, username = None, password = No
return host
+
def getImdb(txt, check_inside = False, multiple = False):
if not check_inside:
@@ -161,10 +177,12 @@ def getImdb(txt, check_inside = False, multiple = False):
return False
+
def tryInt(s, default = 0):
try: return int(s)
except: return default
+
def tryFloat(s):
try:
if isinstance(s, str):
@@ -173,17 +191,24 @@ def tryFloat(s):
return float(s)
except: return 0
+
def natsortKey(s):
return map(tryInt, re.findall(r'(\d+|\D+)', s))
+
def natcmp(a, b):
- return cmp(natsortKey(a), natsortKey(b))
+ a2 = natsortKey(a)
+ b2 = natsortKey(b)
+
+ return (a2 > b2) - (a2 < b2)
+
def toIterable(value):
if isinstance(value, collections.Iterable):
return value
return [value]
+
def getTitle(library_dict):
try:
try:
@@ -206,6 +231,7 @@ def getTitle(library_dict):
log.error('Could not get title for library item: %s', library_dict)
return None
+
def possibleTitles(raw_title):
titles = [
@@ -220,16 +246,20 @@ def possibleTitles(raw_title):
return list(set(titles))
+
def randomString(size = 8, chars = string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for x in range(size))
+
def splitString(str, split_on = ',', clean = True):
- list = [x.strip() for x in str.split(split_on)] if str else []
- return filter(None, list) if clean else list
+ l = [x.strip() for x in str.split(split_on)] if str else []
+ return filter(None, l) if clean else l
+
def dictIsSubset(a, b):
return all([k in b and b[k] == v for k, v in a.items()])
+
def isSubFolder(sub_folder, base_folder):
# Returns True if sub_folder is the same as or inside base_folder
return base_folder and sub_folder and os.path.normpath(base_folder).rstrip(os.path.sep) + os.path.sep in os.path.normpath(sub_folder).rstrip(os.path.sep) + os.path.sep
diff --git a/couchpotato/core/logger.py b/couchpotato/core/logger.py
index 69a031f..c2a7a83 100644
--- a/couchpotato/core/logger.py
+++ b/couchpotato/core/logger.py
@@ -1,6 +1,7 @@
import logging
import re
+
class CPLog(object):
context = ''
@@ -49,7 +50,7 @@ class CPLog(object):
msg = msg % tuple([ss(x) for x in list(replace_tuple)])
else:
msg = msg % ss(replace_tuple)
- except Exception, e:
+ except Exception as e:
self.logger.error(u'Failed encoding stuff to log "%s": %s' % (msg, e))
if not Env.get('dev'):
diff --git a/couchpotato/core/media/__init__.py b/couchpotato/core/media/__init__.py
index 8809489..2635ca6 100644
--- a/couchpotato/core/media/__init__.py
+++ b/couchpotato/core/media/__init__.py
@@ -10,8 +10,8 @@ class MediaBase(Plugin):
default_dict = {
'profile': {'types': {'quality': {}}},
- 'releases': {'status': {}, 'quality': {}, 'files':{}, 'info': {}},
- 'library': {'titles': {}, 'files':{}},
+ 'releases': {'status': {}, 'quality': {}, 'files': {}, 'info': {}},
+ 'library': {'titles': {}, 'files': {}},
'files': {},
'status': {},
'category': {},
diff --git a/couchpotato/core/media/_base/media/__init__.py b/couchpotato/core/media/_base/media/__init__.py
index a9693a3..e5f5a0e 100644
--- a/couchpotato/core/media/_base/media/__init__.py
+++ b/couchpotato/core/media/_base/media/__init__.py
@@ -1,5 +1,6 @@
from .main import MediaPlugin
+
def start():
return MediaPlugin()
diff --git a/couchpotato/core/media/_base/media/main.py b/couchpotato/core/media/_base/media/main.py
index 206187f..b9bf219 100644
--- a/couchpotato/core/media/_base/media/main.py
+++ b/couchpotato/core/media/_base/media/main.py
@@ -102,7 +102,6 @@ class MediaPlugin(MediaBase):
def handler():
fireEvent('library.update.%s' % media.type, identifier = identifier, default_title = default_title, force = True, on_complete = self.createOnComplete(id))
-
return handler
def addSingleRefreshView(self):
@@ -254,7 +253,7 @@ class MediaPlugin(MediaBase):
# Merge releases with movie dict
movies.append(mergeDicts(movie_dict[media_id].to_dict({
- 'library': {'titles': {}, 'files':{}},
+ 'library': {'titles': {}, 'files': {}},
'files': {},
}), {
'releases': releases,
diff --git a/couchpotato/core/media/_base/search/__init__.py b/couchpotato/core/media/_base/search/__init__.py
index 4b2eae2..09bc84e 100644
--- a/couchpotato/core/media/_base/search/__init__.py
+++ b/couchpotato/core/media/_base/search/__init__.py
@@ -1,5 +1,6 @@
from .main import Search
+
def start():
return Search()
diff --git a/couchpotato/core/media/_base/searcher/__init__.py b/couchpotato/core/media/_base/searcher/__init__.py
index 5e029a2..72c7d6e 100644
--- a/couchpotato/core/media/_base/searcher/__init__.py
+++ b/couchpotato/core/media/_base/searcher/__init__.py
@@ -1,5 +1,6 @@
from .main import Searcher
+
def start():
return Searcher()
diff --git a/couchpotato/core/media/_base/searcher/base.py b/couchpotato/core/media/_base/searcher/base.py
index 368c6e2..5322d85 100644
--- a/couchpotato/core/media/_base/searcher/base.py
+++ b/couchpotato/core/media/_base/searcher/base.py
@@ -12,7 +12,6 @@ class SearcherBase(Plugin):
def __init__(self):
super(SearcherBase, self).__init__()
-
addEvent('searcher.progress', self.getProgress)
addEvent('%s.searcher.progress' % self.getType(), self.getProgress)
@@ -26,9 +25,8 @@ class SearcherBase(Plugin):
_type = self.getType()
def setCrons():
-
fireEvent('schedule.cron', '%s.searcher.all' % _type, self.searchAll,
- day = self.conf('cron_day'), hour = self.conf('cron_hour'), minute = self.conf('cron_minute'))
+ day = self.conf('cron_day'), hour = self.conf('cron_hour'), minute = self.conf('cron_minute'))
addEvent('app.load', setCrons)
addEvent('setting.save.%s_searcher.cron_day.after' % _type, setCrons)
diff --git a/couchpotato/core/media/_base/searcher/main.py b/couchpotato/core/media/_base/searcher/main.py
index 3c73eb2..6ff0972 100644
--- a/couchpotato/core/media/_base/searcher/main.py
+++ b/couchpotato/core/media/_base/searcher/main.py
@@ -107,10 +107,10 @@ class Searcher(SearcherBase):
# Hack for older movies that don't contain quality tag
year_name = fireEvent('scanner.name_year', name, single = True)
if len(found) == 0 and movie_year < datetime.datetime.now().year - 3 and not year_name.get('year', None):
- if size > 3000: # Assume dvdr
+ if size > 3000: # Assume dvdr
log.info('Quality was missing in name, assuming it\'s a DVD-R based on the size: %s', size)
found['dvdr'] = True
- else: # Assume dvdrip
+ else: # Assume dvdrip
log.info('Quality was missing in name, assuming it\'s a DVD-Rip based on the size: %s', size)
found['dvdrip'] = True
diff --git a/couchpotato/core/media/movie/_base/__init__.py b/couchpotato/core/media/movie/_base/__init__.py
index 4be3b12..2221133 100644
--- a/couchpotato/core/media/movie/_base/__init__.py
+++ b/couchpotato/core/media/movie/_base/__init__.py
@@ -1,5 +1,6 @@
from .main import MovieBase
+
def start():
return MovieBase()
diff --git a/couchpotato/core/media/movie/_base/main.py b/couchpotato/core/media/movie/_base/main.py
index 03c22e3..cd2158c 100644
--- a/couchpotato/core/media/movie/_base/main.py
+++ b/couchpotato/core/media/movie/_base/main.py
@@ -61,7 +61,6 @@ class MovieBase(MovieTypeBase):
except:
pass
-
library = fireEvent('library.add.movie', single = True, attrs = params, update_after = update_library)
# Status
diff --git a/couchpotato/core/media/movie/library/movie/__init__.py b/couchpotato/core/media/movie/library/movie/__init__.py
index 03494a1..98ed54c 100644
--- a/couchpotato/core/media/movie/library/movie/__init__.py
+++ b/couchpotato/core/media/movie/library/movie/__init__.py
@@ -1,5 +1,6 @@
from .main import MovieLibraryPlugin
+
def start():
return MovieLibraryPlugin()
diff --git a/couchpotato/core/media/movie/library/movie/main.py b/couchpotato/core/media/movie/library/movie/main.py
index b0d0520..61d93ae 100644
--- a/couchpotato/core/media/movie/library/movie/main.py
+++ b/couchpotato/core/media/movie/library/movie/main.py
@@ -13,7 +13,7 @@ log = CPLog(__name__)
class MovieLibraryPlugin(LibraryBase):
- default_dict = {'titles': {}, 'files':{}}
+ default_dict = {'titles': {}, 'files': {}}
def __init__(self):
addEvent('library.add.movie', self.add)
diff --git a/couchpotato/core/media/movie/searcher/__init__.py b/couchpotato/core/media/movie/searcher/__init__.py
index bae1890..4ae1ed3 100644
--- a/couchpotato/core/media/movie/searcher/__init__.py
+++ b/couchpotato/core/media/movie/searcher/__init__.py
@@ -1,6 +1,7 @@
from .main import MovieSearcher
import random
+
def start():
return MovieSearcher()
diff --git a/couchpotato/core/media/movie/searcher/main.py b/couchpotato/core/media/movie/searcher/main.py
index 1c4810e..1775f67 100644
--- a/couchpotato/core/media/movie/searcher/main.py
+++ b/couchpotato/core/media/movie/searcher/main.py
@@ -91,7 +91,7 @@ class MovieSearcher(SearcherBase, MovieTypeBase):
'category': {},
'profile': {'types': {'quality': {}}},
'releases': {'status': {}, 'quality': {}},
- 'library': {'titles': {}, 'files':{}},
+ 'library': {'titles': {}, 'files': {}},
'files': {},
})
@@ -117,7 +117,7 @@ class MovieSearcher(SearcherBase, MovieTypeBase):
def single(self, movie, search_protocols = None, manual = False):
# movies don't contain 'type' yet, so just set to default here
- if not movie.has_key('type'):
+ if 'type' not in movie:
movie['type'] = 'movie'
# Find out search type
diff --git a/couchpotato/core/media/movie/suggestion/__init__.py b/couchpotato/core/media/movie/suggestion/__init__.py
index b63b5b1..50083fe 100644
--- a/couchpotato/core/media/movie/suggestion/__init__.py
+++ b/couchpotato/core/media/movie/suggestion/__init__.py
@@ -1,5 +1,6 @@
from .main import Suggestion
+
def start():
return Suggestion()
diff --git a/couchpotato/core/media/movie/suggestion/main.py b/couchpotato/core/media/movie/suggestion/main.py
index f29281e..5240bb2 100644
--- a/couchpotato/core/media/movie/suggestion/main.py
+++ b/couchpotato/core/media/movie/suggestion/main.py
@@ -40,7 +40,7 @@ class Suggestion(Plugin):
movies.extend(splitString(Env.prop('suggest_seen', default = '')))
suggestions = fireEvent('movie.suggest', movies = movies, ignore = ignored, single = True)
- self.setCache('suggestion_cached', suggestions, timeout = 6048000) # Cache for 10 weeks
+ self.setCache('suggestion_cached', suggestions, timeout = 6048000) # Cache for 10 weeks
return {
'success': True,
diff --git a/couchpotato/core/migration/versions/002_Movie_category.py b/couchpotato/core/migration/versions/002_Movie_category.py
index 234e113..023e47c 100644
--- a/couchpotato/core/migration/versions/002_Movie_category.py
+++ b/couchpotato/core/migration/versions/002_Movie_category.py
@@ -13,5 +13,6 @@ def upgrade(migrate_engine):
create_column(category_column, movie)
Index('ix_movie_category_id', movie.c.category_id).create()
+
def downgrade(migrate_engine):
pass
diff --git a/couchpotato/core/notifications/boxcar/__init__.py b/couchpotato/core/notifications/boxcar/__init__.py
index ab244c3..faab7a5 100644
--- a/couchpotato/core/notifications/boxcar/__init__.py
+++ b/couchpotato/core/notifications/boxcar/__init__.py
@@ -1,5 +1,6 @@
from .main import Boxcar
+
def start():
return Boxcar()
diff --git a/couchpotato/core/notifications/core/__init__.py b/couchpotato/core/notifications/core/__init__.py
index 6e923da..b68a915 100644
--- a/couchpotato/core/notifications/core/__init__.py
+++ b/couchpotato/core/notifications/core/__init__.py
@@ -1,5 +1,6 @@
from .main import CoreNotifier
+
def start():
return CoreNotifier()
diff --git a/couchpotato/core/notifications/core/main.py b/couchpotato/core/notifications/core/main.py
index cd63c2c..02545ea 100644
--- a/couchpotato/core/notifications/core/main.py
+++ b/couchpotato/core/notifications/core/main.py
@@ -71,7 +71,6 @@ class CoreNotifier(Notification):
db.query(Notif).filter(Notif.added <= (int(time.time()) - 2419200)).delete()
db.commit()
-
def markAsRead(self, ids = None, **kwargs):
ids = splitString(ids) if ids else None
diff --git a/couchpotato/core/notifications/email/__init__.py b/couchpotato/core/notifications/email/__init__.py
index 33c2f63..aaf087b 100644
--- a/couchpotato/core/notifications/email/__init__.py
+++ b/couchpotato/core/notifications/email/__init__.py
@@ -1,5 +1,6 @@
from .main import Email
+
def start():
return Email()
@@ -30,7 +31,7 @@ config = [{
},
{ 'name': 'smtp_port',
'label': 'SMTP server port',
- 'default': '25',
+ 'default': '25',
'type': 'int',
},
{
diff --git a/couchpotato/core/notifications/email/main.py b/couchpotato/core/notifications/email/main.py
index 41a4323..b854401 100644
--- a/couchpotato/core/notifications/email/main.py
+++ b/couchpotato/core/notifications/email/main.py
@@ -40,7 +40,7 @@ class Email(Notification):
log.debug("SMTP over SSL %s", ("enabled" if ssl == 1 else "disabled"))
mailserver = smtplib.SMTP_SSL(smtp_server) if ssl == 1 else smtplib.SMTP(smtp_server)
- if (starttls):
+ if starttls:
log.debug("Using StartTLS to initiate the connection with the SMTP server")
mailserver.starttls()
diff --git a/couchpotato/core/notifications/growl/__init__.py b/couchpotato/core/notifications/growl/__init__.py
index 8e46223..dd01cb9 100644
--- a/couchpotato/core/notifications/growl/__init__.py
+++ b/couchpotato/core/notifications/growl/__init__.py
@@ -1,5 +1,6 @@
from .main import Growl
+
def start():
return Growl()
diff --git a/couchpotato/core/notifications/growl/main.py b/couchpotato/core/notifications/growl/main.py
index dabeea0..a3927ed 100644
--- a/couchpotato/core/notifications/growl/main.py
+++ b/couchpotato/core/notifications/growl/main.py
@@ -37,7 +37,7 @@ class Growl(Notification):
)
self.growl.register()
self.registered = True
- except Exception, e:
+ except Exception as e:
if 'timed out' in str(e):
self.registered = True
else:
diff --git a/couchpotato/core/notifications/nmj/__init__.py b/couchpotato/core/notifications/nmj/__init__.py
index 08a21a3..461a450 100644
--- a/couchpotato/core/notifications/nmj/__init__.py
+++ b/couchpotato/core/notifications/nmj/__init__.py
@@ -1,5 +1,6 @@
from .main import NMJ
+
def start():
return NMJ()
diff --git a/couchpotato/core/notifications/nmj/main.py b/couchpotato/core/notifications/nmj/main.py
index 1479fb1..967b70e 100644
--- a/couchpotato/core/notifications/nmj/main.py
+++ b/couchpotato/core/notifications/nmj/main.py
@@ -86,18 +86,17 @@ class NMJ(Notification):
'arg3': '',
}
params = tryUrlencode(params)
- UPDATE_URL = 'http://%(host)s:8008/metadata_database?%(params)s'
- updateUrl = UPDATE_URL % {'host': host, 'params': params}
+ update_url = 'http://%(host)s:8008/metadata_database?%(params)s' % {'host': host, 'params': params}
try:
- response = self.urlopen(updateUrl)
+ response = self.urlopen(update_url)
except:
return False
try:
et = etree.fromstring(response)
result = et.findtext('returnValue')
- except SyntaxError, e:
+ except SyntaxError as e:
log.error('Unable to parse XML returned from the Popcorn Hour: %s', e)
return False
diff --git a/couchpotato/core/notifications/notifymyandroid/__init__.py b/couchpotato/core/notifications/notifymyandroid/__init__.py
index 9ee5d90..7d4f4ae 100644
--- a/couchpotato/core/notifications/notifymyandroid/__init__.py
+++ b/couchpotato/core/notifications/notifymyandroid/__init__.py
@@ -1,5 +1,6 @@
from .main import NotifyMyAndroid
+
def start():
return NotifyMyAndroid()
diff --git a/couchpotato/core/notifications/notifymywp/__init__.py b/couchpotato/core/notifications/notifymywp/__init__.py
index 6e0bd06..4fcf1a9 100644
--- a/couchpotato/core/notifications/notifymywp/__init__.py
+++ b/couchpotato/core/notifications/notifymywp/__init__.py
@@ -1,5 +1,6 @@
from .main import NotifyMyWP
+
def start():
return NotifyMyWP()
diff --git a/couchpotato/core/notifications/notifymywp/main.py b/couchpotato/core/notifications/notifymywp/main.py
index 167b6ee..1cdd980 100644
--- a/couchpotato/core/notifications/notifymywp/main.py
+++ b/couchpotato/core/notifications/notifymywp/main.py
@@ -8,7 +8,8 @@ log = CPLog(__name__)
class NotifyMyWP(Notification):
- def notify(self, message = '', data = {}, listener = None):
+ def notify(self, message = '', data = None, listener = None):
+ if not data: data = {}
keys = splitString(self.conf('api_key'))
p = PyNMWP(keys, self.conf('dev_key'))
diff --git a/couchpotato/core/notifications/plex/__init__.py b/couchpotato/core/notifications/plex/__init__.py
index d68ddb1..0de92ca 100755
--- a/couchpotato/core/notifications/plex/__init__.py
+++ b/couchpotato/core/notifications/plex/__init__.py
@@ -1,5 +1,6 @@
from .main import Plex
+
def start():
return Plex()
diff --git a/couchpotato/core/notifications/plex/main.py b/couchpotato/core/notifications/plex/main.py
index ce25c8f..a6853b2 100755
--- a/couchpotato/core/notifications/plex/main.py
+++ b/couchpotato/core/notifications/plex/main.py
@@ -23,9 +23,9 @@ class Plex(Notification):
addEvent('renamer.after', self.addToLibrary)
-
- def addToLibrary(self, message = None, group = {}):
+ def addToLibrary(self, message = None, group = None):
if self.isDisabled(): return
+ if not group: group = {}
return self.server.refresh()
@@ -57,7 +57,8 @@ class Plex(Notification):
return success
- def notify(self, message = '', data = {}, listener = None):
+ def notify(self, message = '', data = None, listener = None):
+ if not data: data = {}
return self.notifyClients(message, self.getClientNames())
def test(self, **kwargs):
diff --git a/couchpotato/core/notifications/prowl/__init__.py b/couchpotato/core/notifications/prowl/__init__.py
index e056428..3721a0a 100644
--- a/couchpotato/core/notifications/prowl/__init__.py
+++ b/couchpotato/core/notifications/prowl/__init__.py
@@ -1,5 +1,6 @@
from .main import Prowl
+
def start():
return Prowl()
diff --git a/couchpotato/core/notifications/prowl/main.py b/couchpotato/core/notifications/prowl/main.py
index 26e156a..b338586 100644
--- a/couchpotato/core/notifications/prowl/main.py
+++ b/couchpotato/core/notifications/prowl/main.py
@@ -22,7 +22,7 @@ class Prowl(Notification):
'priority': self.conf('priority'),
}
headers = {
- 'Content-type': 'application/x-www-form-urlencoded'
+ 'Content-type': 'application/x-www-form-urlencoded'
}
try:
diff --git a/couchpotato/core/notifications/pushalot/__init__.py b/couchpotato/core/notifications/pushalot/__init__.py
index a2a297a..ad0c853 100644
--- a/couchpotato/core/notifications/pushalot/__init__.py
+++ b/couchpotato/core/notifications/pushalot/__init__.py
@@ -1,5 +1,6 @@
from .main import Pushalot
+
def start():
return Pushalot()
diff --git a/couchpotato/core/notifications/pushalot/main.py b/couchpotato/core/notifications/pushalot/main.py
index 0afb84b..306ee1d 100644
--- a/couchpotato/core/notifications/pushalot/main.py
+++ b/couchpotato/core/notifications/pushalot/main.py
@@ -5,6 +5,7 @@ import traceback
log = CPLog(__name__)
+
class Pushalot(Notification):
urls = {
diff --git a/couchpotato/core/notifications/pushbullet/__init__.py b/couchpotato/core/notifications/pushbullet/__init__.py
index e61a44e..c52e778 100644
--- a/couchpotato/core/notifications/pushbullet/__init__.py
+++ b/couchpotato/core/notifications/pushbullet/__init__.py
@@ -1,5 +1,6 @@
from .main import Pushbullet
+
def start():
return Pushbullet()
diff --git a/couchpotato/core/notifications/pushover/__init__.py b/couchpotato/core/notifications/pushover/__init__.py
index 1ea1d5c..da76486 100644
--- a/couchpotato/core/notifications/pushover/__init__.py
+++ b/couchpotato/core/notifications/pushover/__init__.py
@@ -1,5 +1,6 @@
from .main import Pushover
+
def start():
return Pushover()
diff --git a/couchpotato/core/notifications/pushover/main.py b/couchpotato/core/notifications/pushover/main.py
index 76f730b..ba954a5 100644
--- a/couchpotato/core/notifications/pushover/main.py
+++ b/couchpotato/core/notifications/pushover/main.py
@@ -30,9 +30,9 @@ class Pushover(Notification):
})
http_handler.request('POST',
- "/1/messages.json",
- headers = {'Content-type': 'application/x-www-form-urlencoded'},
- body = tryUrlencode(api_data)
+ "/1/messages.json",
+ headers = {'Content-type': 'application/x-www-form-urlencoded'},
+ body = tryUrlencode(api_data)
)
response = http_handler.getresponse()
diff --git a/couchpotato/core/notifications/synoindex/__init__.py b/couchpotato/core/notifications/synoindex/__init__.py
index eb3a793..89d07b0 100644
--- a/couchpotato/core/notifications/synoindex/__init__.py
+++ b/couchpotato/core/notifications/synoindex/__init__.py
@@ -1,5 +1,6 @@
from .main import Synoindex
+
def start():
return Synoindex()
diff --git a/couchpotato/core/notifications/synoindex/main.py b/couchpotato/core/notifications/synoindex/main.py
index 0f7775d..ec7a64e 100644
--- a/couchpotato/core/notifications/synoindex/main.py
+++ b/couchpotato/core/notifications/synoindex/main.py
@@ -26,7 +26,7 @@ class Synoindex(Notification):
out = p.communicate()
log.info('Result from synoindex: %s', str(out))
return True
- except OSError, e:
+ except OSError as e:
log.error('Unable to run synoindex: %s', e)
return False
diff --git a/couchpotato/core/notifications/toasty/__init__.py b/couchpotato/core/notifications/toasty/__init__.py
index 8e2dae7..31e055a 100644
--- a/couchpotato/core/notifications/toasty/__init__.py
+++ b/couchpotato/core/notifications/toasty/__init__.py
@@ -1,5 +1,6 @@
from .main import Toasty
+
def start():
return Toasty()
diff --git a/couchpotato/core/notifications/toasty/main.py b/couchpotato/core/notifications/toasty/main.py
index c65b6b4..ea1f219 100644
--- a/couchpotato/core/notifications/toasty/main.py
+++ b/couchpotato/core/notifications/toasty/main.py
@@ -5,6 +5,7 @@ import traceback
log = CPLog(__name__)
+
class Toasty(Notification):
urls = {
diff --git a/couchpotato/core/notifications/trakt/__init__.py b/couchpotato/core/notifications/trakt/__init__.py
index b119736..20e2e3f 100644
--- a/couchpotato/core/notifications/trakt/__init__.py
+++ b/couchpotato/core/notifications/trakt/__init__.py
@@ -1,5 +1,6 @@
from .main import Trakt
+
def start():
return Trakt()
diff --git a/couchpotato/core/notifications/trakt/main.py b/couchpotato/core/notifications/trakt/main.py
index e67f5fa..c759c6d 100644
--- a/couchpotato/core/notifications/trakt/main.py
+++ b/couchpotato/core/notifications/trakt/main.py
@@ -3,6 +3,7 @@ from couchpotato.core.notifications.base import Notification
log = CPLog(__name__)
+
class Trakt(Notification):
urls = {
diff --git a/couchpotato/core/notifications/twitter/__init__.py b/couchpotato/core/notifications/twitter/__init__.py
index 9db8dcb..1b9c769 100644
--- a/couchpotato/core/notifications/twitter/__init__.py
+++ b/couchpotato/core/notifications/twitter/__init__.py
@@ -1,5 +1,6 @@
from .main import Twitter
+
def start():
return Twitter()
diff --git a/couchpotato/core/notifications/twitter/main.py b/couchpotato/core/notifications/twitter/main.py
index ad4fc31..559c830 100644
--- a/couchpotato/core/notifications/twitter/main.py
+++ b/couchpotato/core/notifications/twitter/main.py
@@ -64,7 +64,7 @@ class Twitter(Notification):
api.PostUpdate(update_message[135:] + ' 2/2')
else:
api.PostUpdate(update_message)
- except Exception, e:
+ except Exception as e:
log.error('Error sending tweet: %s', e)
return False
diff --git a/couchpotato/core/notifications/xbmc/__init__.py b/couchpotato/core/notifications/xbmc/__init__.py
index 04662e2..34fed63 100644
--- a/couchpotato/core/notifications/xbmc/__init__.py
+++ b/couchpotato/core/notifications/xbmc/__init__.py
@@ -1,5 +1,6 @@
from .main import XBMC
+
def start():
return XBMC()
diff --git a/couchpotato/core/notifications/xbmc/main.py b/couchpotato/core/notifications/xbmc/main.py
index b53485a..bfda85e 100755
--- a/couchpotato/core/notifications/xbmc/main.py
+++ b/couchpotato/core/notifications/xbmc/main.py
@@ -1,7 +1,6 @@
from couchpotato.core.helpers.variable import splitString
from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification
-from urllib2 import URLError
import base64
import json
import socket
@@ -46,7 +45,7 @@ class XBMC(Notification):
max_successful += len(calls)
response = self.request(host, calls)
else:
- response = self.notifyXBMCnoJSON(host, {'title':self.default_title, 'message':message})
+ response = self.notifyXBMCnoJSON(host, {'title': self.default_title, 'message': message})
if data and data.get('destination_dir') and (not self.conf('only_first') or hosts.index(host) == 0):
response += self.request(host, [('VideoLibrary.Scan', {})])
diff --git a/couchpotato/core/notifications/xmpp/__init__.py b/couchpotato/core/notifications/xmpp/__init__.py
index a52242f..0e3e14d 100644
--- a/couchpotato/core/notifications/xmpp/__init__.py
+++ b/couchpotato/core/notifications/xmpp/__init__.py
@@ -1,5 +1,6 @@
from .main import Xmpp
+
def start():
return Xmpp()
diff --git a/couchpotato/core/plugins/automation/__init__.py b/couchpotato/core/plugins/automation/__init__.py
index a81719c..482a009 100644
--- a/couchpotato/core/plugins/automation/__init__.py
+++ b/couchpotato/core/plugins/automation/__init__.py
@@ -1,5 +1,6 @@
from .main import Automation
+
def start():
return Automation()
diff --git a/couchpotato/core/plugins/base.py b/couchpotato/core/plugins/base.py
index b4688e4..73e41c7 100644
--- a/couchpotato/core/plugins/base.py
+++ b/couchpotato/core/plugins/base.py
@@ -85,7 +85,7 @@ class Plugin(object):
class_name = re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
# View path
- path = 'static/plugin/%s/' % (class_name)
+ path = 'static/plugin/%s/' % class_name
# Add handler to Tornado
Env.get('app').add_handlers(".*$", [(Env.get('web_base') + path + '(.*)', StaticFileHandler, {'path': static_folder})])
@@ -110,7 +110,7 @@ class Plugin(object):
f.write(content)
f.close()
os.chmod(path, Env.getPermission('file'))
- except Exception, e:
+ except Exception as e:
log.error('Unable writing to file "%s": %s', (path, traceback.format_exc()))
if os.path.isfile(path):
os.remove(path)
@@ -121,7 +121,7 @@ class Plugin(object):
if not os.path.isdir(path):
os.makedirs(path, Env.getPermission('folder'))
return True
- except Exception, e:
+ except Exception as e:
log.error('Unable to create folder "%s": %s', (path, e))
return False
@@ -243,7 +243,6 @@ class Plugin(object):
except:
log.error("Something went wrong when finishing the plugin function. Could not find the 'is_running' key")
-
def getCache(self, cache_key, url = None, **kwargs):
cache_key_md5 = md5(cache_key)
cache = Env.get('cache').get(cache_key_md5)
@@ -255,7 +254,7 @@ class Plugin(object):
try:
cache_timeout = 300
- if kwargs.has_key('cache_timeout'):
+ if 'cache_timeout' in kwargs:
cache_timeout = kwargs.get('cache_timeout')
del kwargs['cache_timeout']
diff --git a/couchpotato/core/plugins/browser/__init__.py b/couchpotato/core/plugins/browser/__init__.py
index 976fcd1..fae5065 100644
--- a/couchpotato/core/plugins/browser/__init__.py
+++ b/couchpotato/core/plugins/browser/__init__.py
@@ -1,5 +1,6 @@
from .main import FileBrowser
+
def start():
return FileBrowser()
diff --git a/couchpotato/core/plugins/browser/main.py b/couchpotato/core/plugins/browser/main.py
index 380e682..c8f7536 100644
--- a/couchpotato/core/plugins/browser/main.py
+++ b/couchpotato/core/plugins/browser/main.py
@@ -14,7 +14,7 @@ if os.name == 'nt':
raise ImportError("Missing the win32file module, which is a part of the prerequisite \
pywin32 package. You can get it from http://sourceforge.net/projects/pywin32/files/pywin32/")
else:
- import win32file #@UnresolvedImport
+ import win32file #@UnresolvedImport
class FileBrowser(Plugin):
diff --git a/couchpotato/core/plugins/category/__init__.py b/couchpotato/core/plugins/category/__init__.py
index 6dc41df..dcdae90 100644
--- a/couchpotato/core/plugins/category/__init__.py
+++ b/couchpotato/core/plugins/category/__init__.py
@@ -1,5 +1,6 @@
from .main import CategoryPlugin
+
def start():
return CategoryPlugin()
diff --git a/couchpotato/core/plugins/category/main.py b/couchpotato/core/plugins/category/main.py
index 87cd0ea..35597fd 100644
--- a/couchpotato/core/plugins/category/main.py
+++ b/couchpotato/core/plugins/category/main.py
@@ -101,7 +101,7 @@ class CategoryPlugin(Plugin):
self.removeFromMovie(id)
success = True
- except Exception, e:
+ except Exception as e:
message = log.error('Failed deleting category: %s', e)
db.expire_all()
diff --git a/couchpotato/core/plugins/custom/__init__.py b/couchpotato/core/plugins/custom/__init__.py
index 573cd99..20a3935 100644
--- a/couchpotato/core/plugins/custom/__init__.py
+++ b/couchpotato/core/plugins/custom/__init__.py
@@ -1,5 +1,6 @@
from .main import Custom
+
def start():
return Custom()
diff --git a/couchpotato/core/plugins/dashboard/__init__.py b/couchpotato/core/plugins/dashboard/__init__.py
index 8127929..c43a44e 100644
--- a/couchpotato/core/plugins/dashboard/__init__.py
+++ b/couchpotato/core/plugins/dashboard/__init__.py
@@ -1,5 +1,6 @@
from .main import Dashboard
+
def start():
return Dashboard()
diff --git a/couchpotato/core/plugins/dashboard/main.py b/couchpotato/core/plugins/dashboard/main.py
index 4f4d85a..949d8f5 100644
--- a/couchpotato/core/plugins/dashboard/main.py
+++ b/couchpotato/core/plugins/dashboard/main.py
@@ -115,7 +115,7 @@ class Dashboard(Plugin):
for movie_id in movie_ids:
movies.append(movie_dict[movie_id].to_dict({
- 'library': {'titles': {}, 'files':{}},
+ 'library': {'titles': {}, 'files': {}},
'files': {},
}))
diff --git a/couchpotato/core/plugins/file/__init__.py b/couchpotato/core/plugins/file/__init__.py
index 54d9cbe..3dced3d 100644
--- a/couchpotato/core/plugins/file/__init__.py
+++ b/couchpotato/core/plugins/file/__init__.py
@@ -1,5 +1,6 @@
from .main import FileManager
+
def start():
return FileManager()
diff --git a/couchpotato/core/plugins/file/main.py b/couchpotato/core/plugins/file/main.py
index fc63aca..806af16 100644
--- a/couchpotato/core/plugins/file/main.py
+++ b/couchpotato/core/plugins/file/main.py
@@ -82,7 +82,6 @@ class FileManager(Plugin):
def showCacheFile(self, route, **kwargs):
Env.get('app').add_handlers(".*$", [('%s%s' % (Env.get('api_base'), route), StaticFileHandler, {'path': Env.get('cache_dir')})])
-
def download(self, url = '', dest = None, overwrite = False, urlopen_kwargs = None):
if not urlopen_kwargs: urlopen_kwargs = {}
diff --git a/couchpotato/core/plugins/log/__init__.py b/couchpotato/core/plugins/log/__init__.py
index 33dcf33..f5d9d10 100644
--- a/couchpotato/core/plugins/log/__init__.py
+++ b/couchpotato/core/plugins/log/__init__.py
@@ -1,5 +1,6 @@
from .main import Logging
+
def start():
return Logging()
diff --git a/couchpotato/core/plugins/log/main.py b/couchpotato/core/plugins/log/main.py
index dc8f740..2f47158 100644
--- a/couchpotato/core/plugins/log/main.py
+++ b/couchpotato/core/plugins/log/main.py
@@ -42,7 +42,7 @@ class Logging(Plugin):
'desc': 'Log errors',
'params': {
'type': {'desc': 'Type of logging, default "error"'},
- '**kwargs': {'type':'object', 'desc': 'All other params will be printed in the log string.'},
+ '**kwargs': {'type': 'object', 'desc': 'All other params will be printed in the log string.'},
}
})
diff --git a/couchpotato/core/plugins/manage/__init__.py b/couchpotato/core/plugins/manage/__init__.py
index 912296b..c992dee 100644
--- a/couchpotato/core/plugins/manage/__init__.py
+++ b/couchpotato/core/plugins/manage/__init__.py
@@ -1,5 +1,6 @@
from .main import Manage
+
def start():
return Manage()
diff --git a/couchpotato/core/plugins/manage/main.py b/couchpotato/core/plugins/manage/main.py
index a764f31..3b684f9 100644
--- a/couchpotato/core/plugins/manage/main.py
+++ b/couchpotato/core/plugins/manage/main.py
@@ -14,6 +14,7 @@ import traceback
log = CPLog(__name__)
+
class Manage(Plugin):
in_progress = False
diff --git a/couchpotato/core/plugins/profile/__init__.py b/couchpotato/core/plugins/profile/__init__.py
index ac19b01..c07bc7c 100644
--- a/couchpotato/core/plugins/profile/__init__.py
+++ b/couchpotato/core/plugins/profile/__init__.py
@@ -1,5 +1,6 @@
from .main import ProfilePlugin
+
def start():
return ProfilePlugin()
diff --git a/couchpotato/core/plugins/profile/main.py b/couchpotato/core/plugins/profile/main.py
index 9ff3ead..374bc92 100644
--- a/couchpotato/core/plugins/profile/main.py
+++ b/couchpotato/core/plugins/profile/main.py
@@ -149,7 +149,7 @@ class ProfilePlugin(Plugin):
self.forceDefaults()
success = True
- except Exception, e:
+ except Exception as e:
message = log.error('Failed deleting Profile: %s', e)
db.expire_all()
diff --git a/couchpotato/core/plugins/quality/__init__.py b/couchpotato/core/plugins/quality/__init__.py
index e1b97ad..2630f1a 100644
--- a/couchpotato/core/plugins/quality/__init__.py
+++ b/couchpotato/core/plugins/quality/__init__.py
@@ -1,5 +1,6 @@
from .main import QualityPlugin
+
def start():
return QualityPlugin()
diff --git a/couchpotato/core/plugins/quality/main.py b/couchpotato/core/plugins/quality/main.py
index ed12d01..a49c17e 100644
--- a/couchpotato/core/plugins/quality/main.py
+++ b/couchpotato/core/plugins/quality/main.py
@@ -133,10 +133,10 @@ class QualityPlugin(Plugin):
# Create single quality profile
prof = db.query(Profile).filter(
- Profile.core == True
- ).filter(
- Profile.types.any(quality = qual)
- ).all()
+ Profile.core == True
+ ).filter(
+ Profile.types.any(quality = qual)
+ ).all()
if not prof:
log.info('Creating profile: %s', q.get('label'))
diff --git a/couchpotato/core/plugins/release/__init__.py b/couchpotato/core/plugins/release/__init__.py
index b6a667c..08c6a57 100644
--- a/couchpotato/core/plugins/release/__init__.py
+++ b/couchpotato/core/plugins/release/__init__.py
@@ -1,5 +1,6 @@
from .main import Release
+
def start():
return Release()
diff --git a/couchpotato/core/plugins/release/main.py b/couchpotato/core/plugins/release/main.py
index e5b6d92..2d67d12 100644
--- a/couchpotato/core/plugins/release/main.py
+++ b/couchpotato/core/plugins/release/main.py
@@ -96,7 +96,6 @@ class Release(Plugin):
identifier = '%s.%s.%s' % (group['library']['identifier'], group['meta_data'].get('audio', 'unknown'), group['meta_data']['quality']['identifier'])
-
done_status, snatched_status = fireEvent('status.get', ['done', 'snatched'], single = True)
# Add movie
@@ -237,15 +236,15 @@ class Release(Plugin):
success = self.download(data = item, media = rel.movie.to_dict({
'profile': {'types': {'quality': {}}},
'releases': {'status': {}, 'quality': {}},
- 'library': {'titles': {}, 'files':{}},
+ 'library': {'titles': {}, 'files': {}},
'files': {}
}), manual = True)
- if success == True:
- db.expunge_all()
- rel = db.query(Relea).filter_by(id = id).first() # Get release again @RuudBurger why do we need to get it again??
+ db.expunge_all()
+ if success:
fireEvent('notify.frontend', type = 'release.manual_download', data = True, message = 'Successfully snatched "%s"' % item['name'])
+
return {
'success': success == True
}
@@ -317,8 +316,8 @@ class Release(Plugin):
# If renamer isn't used, mark media done if finished or release downloaded
else:
if media['status_id'] == active_status.get('id'):
- finished = next((True for profile_type in media['profile']['types'] if \
- profile_type['quality_id'] == rls.quality.id and profile_type['finish']), False)
+ finished = next((True for profile_type in media['profile']['types']
+ if profile_type['quality_id'] == rls.quality.id and profile_type['finish']), False)
if finished:
log.info('Renamer disabled, marking media as finished: %s', log_movie)
@@ -423,7 +422,7 @@ class Release(Plugin):
.filter(Relea.movie_id == id) \
.all()
- releases = [r.to_dict({'info':{}, 'files':{}}) for r in releases_raw]
+ releases = [r.to_dict({'info': {}, 'files': {}}) for r in releases_raw]
releases = sorted(releases, key = lambda k: k['info'].get('score', 0), reverse = True)
return releases
@@ -449,6 +448,7 @@ class Release(Plugin):
for info in rel.info:
item[info.identifier] = info.value
+ release_name = None
if rel.files:
for file_item in rel.files:
if file_item.type.identifier == 'movie':
@@ -456,6 +456,7 @@ class Release(Plugin):
break
else:
release_name = item['name']
+
#update status in Db
log.debug('Marking release %s as %s', (release_name, status.get("label")))
rel.status_id = status.get('id')
diff --git a/couchpotato/core/plugins/renamer/__init__.py b/couchpotato/core/plugins/renamer/__init__.py
index 8b602cb..e238f5e 100755
--- a/couchpotato/core/plugins/renamer/__init__.py
+++ b/couchpotato/core/plugins/renamer/__init__.py
@@ -1,6 +1,7 @@
from couchpotato.core.plugins.renamer.main import Renamer
import os
+
def start():
return Renamer()
@@ -136,7 +137,8 @@ config = [{
'default': 'link',
'type': 'dropdown',
'values': [('Link', 'link'), ('Copy', 'copy'), ('Move', 'move')],
- 'description': ('Link, Copy or Move after download completed.', 'Link first tries hard link, then sym link and falls back to Copy. It is perfered to use link when downloading torrents as it will save you space, while still beeing able to seed.'),
+ 'description': ('Link, Copy or Move after download completed.',
+ 'Link first tries hard link, then sym link and falls back to Copy. It is perfered to use link when downloading torrents as it will save you space, while still beeing able to seed.'),
'advanced': True,
},
{
diff --git a/couchpotato/core/plugins/renamer/main.py b/couchpotato/core/plugins/renamer/main.py
index 68a8fe4..9ba1c09 100755
--- a/couchpotato/core/plugins/renamer/main.py
+++ b/couchpotato/core/plugins/renamer/main.py
@@ -20,6 +20,7 @@ import traceback
log = CPLog(__name__)
+
class Renamer(Plugin):
renaming_started = False
@@ -33,7 +34,7 @@ class Renamer(Plugin):
'media_folder': {'desc': 'Optional: The folder of the media to scan. Keep empty for default renamer folder.'},
'files': {'desc': 'Optional: Provide the release files if more releases are in the same media_folder, delimited with a \'|\'. Note that no dedicated release folder is expected for releases with one file.'},
'base_folder': {'desc': 'Optional: The folder to find releases in. Leave empty for default folder.'},
- 'downloader' : {'desc': 'Optional: The downloader the release has been downloaded with. \'download_id\' is required with this option.'},
+ 'downloader': {'desc': 'Optional: The downloader the release has been downloaded with. \'download_id\' is required with this option.'},
'download_id': {'desc': 'Optional: The nzb/torrent ID of the release in media_folder. \'downloader\' is required with this option.'},
'status': {'desc': 'Optional: The status of the release: \'completed\' (default) or \'seeding\''},
},
@@ -274,25 +275,25 @@ class Renamer(Plugin):
name_the = movie_name[4:] + ', The'
replacements = {
- 'ext': 'mkv',
- 'namethe': name_the.strip(),
- 'thename': movie_name.strip(),
- 'year': library['year'],
- 'first': name_the[0].upper(),
- 'quality': group['meta_data']['quality']['label'],
- 'quality_type': group['meta_data']['quality_type'],
- 'video': group['meta_data'].get('video'),
- 'audio': group['meta_data'].get('audio'),
- 'group': group['meta_data']['group'],
- 'source': group['meta_data']['source'],
- 'resolution_width': group['meta_data'].get('resolution_width'),
- 'resolution_height': group['meta_data'].get('resolution_height'),
- 'audio_channels': group['meta_data'].get('audio_channels'),
- 'imdb_id': library['identifier'],
- 'cd': '',
- 'cd_nr': '',
- 'mpaa': library['info'].get('mpaa', ''),
- 'category': category_label,
+ 'ext': 'mkv',
+ 'namethe': name_the.strip(),
+ 'thename': movie_name.strip(),
+ 'year': library['year'],
+ 'first': name_the[0].upper(),
+ 'quality': group['meta_data']['quality']['label'],
+ 'quality_type': group['meta_data']['quality_type'],
+ 'video': group['meta_data'].get('video'),
+ 'audio': group['meta_data'].get('audio'),
+ 'group': group['meta_data']['group'],
+ 'source': group['meta_data']['source'],
+ 'resolution_width': group['meta_data'].get('resolution_width'),
+ 'resolution_height': group['meta_data'].get('resolution_height'),
+ 'audio_channels': group['meta_data'].get('audio_channels'),
+ 'imdb_id': library['identifier'],
+ 'cd': '',
+ 'cd_nr': '',
+ 'mpaa': library['info'].get('mpaa', ''),
+ 'category': category_label,
}
for file_type in group['files']:
@@ -434,7 +435,7 @@ class Renamer(Plugin):
movie.status_id = done_status.get('id')
movie.last_edit = int(time.time())
db.commit()
- except Exception, e:
+ except Exception as e:
log.error('Failed marking movie finished: %s %s', (e, traceback.format_exc()))
# Go over current movie releases
@@ -526,7 +527,7 @@ class Renamer(Plugin):
for delete_folder in delete_folders:
try:
self.deleteEmptyFolder(delete_folder, show_error = False)
- except Exception, e:
+ except Exception as e:
log.error('Failed to delete folder: %s %s', (e, traceback.format_exc()))
# Rename all files marked
@@ -592,7 +593,7 @@ class Renamer(Plugin):
# Break if CP wants to shut down
if self.shuttingDown():
break
-
+
self.renaming_started = False
def getRenameExtras(self, extra_type = '', replacements = None, folder_name = '', file_name = '', destination = '', group = None, current_file = '', remove_multiple = False):
@@ -1160,7 +1161,7 @@ Remove it if you want it to be renamed (again, or at least let it try again)
rar_handle.extract(condition = [packedinfo.index], path = extr_path, withSubpath = False, overwrite = False)
extr_files.append(sp(os.path.join(extr_path, os.path.basename(packedinfo.filename))))
del rar_handle
- except Exception, e:
+ except Exception as e:
log.error('Failed to extract %s: %s %s', (archive['file'], e, traceback.format_exc()))
continue
@@ -1169,7 +1170,7 @@ Remove it if you want it to be renamed (again, or at least let it try again)
if cleanup:
try:
os.remove(filename)
- except Exception, e:
+ except Exception as e:
log.error('Failed to remove %s: %s %s', (filename, e, traceback.format_exc()))
continue
files.remove(filename)
@@ -1182,7 +1183,7 @@ Remove it if you want it to be renamed (again, or at least let it try again)
try:
self.makeDir(os.path.dirname(move_to))
self.moveFile(leftoverfile, move_to, cleanup)
- except Exception, e:
+ except Exception as e:
log.error('Failed moving left over file %s to %s: %s %s', (leftoverfile, move_to, e, traceback.format_exc()))
# As we probably tried to overwrite the nfo file, check if it exists and then remove the original
if os.path.isfile(move_to):
diff --git a/couchpotato/core/plugins/scanner/__init__.py b/couchpotato/core/plugins/scanner/__init__.py
index 3d64046..66c6b39 100644
--- a/couchpotato/core/plugins/scanner/__init__.py
+++ b/couchpotato/core/plugins/scanner/__init__.py
@@ -1,5 +1,6 @@
from .main import Scanner
+
def start():
return Scanner()
diff --git a/couchpotato/core/plugins/scanner/main.py b/couchpotato/core/plugins/scanner/main.py
index 1cb66ce..4f8f2ab 100644
--- a/couchpotato/core/plugins/scanner/main.py
+++ b/couchpotato/core/plugins/scanner/main.py
@@ -23,7 +23,7 @@ class Scanner(Plugin):
ignored_in_path = [os.path.sep + 'extracted' + os.path.sep, 'extracting', '_unpack', '_failed_', '_unknown_', '_exists_', '_failed_remove_',
'_failed_rename_', '.appledouble', '.appledb', '.appledesktop', os.path.sep + '._', '.ds_store', 'cp.cpnfo',
- 'thumbs.db', 'ehthumbs.db', 'desktop.ini'] #unpacking, smb-crap, hidden files
+ 'thumbs.db', 'ehthumbs.db', 'desktop.ini'] #unpacking, smb-crap, hidden files
ignore_names = ['extract', 'extracting', 'extracted', 'movie', 'movies', 'film', 'films', 'download', 'downloads', 'video_ts', 'audio_ts', 'bdmv', 'certificate']
extensions = {
'movie': ['mkv', 'wmv', 'avi', 'mpg', 'mpeg', 'mp4', 'm2ts', 'iso', 'img', 'mdf', 'ts', 'm4v'],
@@ -48,7 +48,7 @@ class Scanner(Plugin):
'leftover': ('leftover', 'leftover'),
}
- file_sizes = { # in MB
+ file_sizes = { # in MB
'movie': {'min': 300},
'trailer': {'min': 2, 'max': 250},
'backdrop': {'min': 0, 'max': 5},
@@ -83,17 +83,17 @@ class Scanner(Plugin):
clean = '[ _\,\.\(\)\[\]\-]?(extended.cut|directors.cut|french|swedisch|danish|dutch|swesub|spanish|german|ac3|dts|custom|dc|divx|divx5|dsr|dsrip|dutch|dvd|dvdr|dvdrip|dvdscr|dvdscreener|screener|dvdivx|cam|fragment|fs|hdtv|hdrip' \
'|hdtvrip|internal|limited|multisubs|ntsc|ogg|ogm|pal|pdtv|proper|repack|rerip|retail|r3|r5|bd5|se|svcd|swedish|german|read.nfo|nfofix|unrated|ws|telesync|ts|telecine|tc|brrip|bdrip|video_ts|audio_ts|480p|480i|576p|576i|720p|720i|1080p|1080i|hrhd|hrhdtv|hddvd|bluray|x264|h264|xvid|xvidvd|xxx|www.www|cd[1-9]|\[.*\])([ _\,\.\(\)\[\]\-]|$)'
multipart_regex = [
- '[ _\.-]+cd[ _\.-]*([0-9a-d]+)', #*cd1
- '[ _\.-]+dvd[ _\.-]*([0-9a-d]+)', #*dvd1
- '[ _\.-]+part[ _\.-]*([0-9a-d]+)', #*part1
- '[ _\.-]+dis[ck][ _\.-]*([0-9a-d]+)', #*disk1
- 'cd[ _\.-]*([0-9a-d]+)$', #cd1.ext
- 'dvd[ _\.-]*([0-9a-d]+)$', #dvd1.ext
- 'part[ _\.-]*([0-9a-d]+)$', #part1.mkv
- 'dis[ck][ _\.-]*([0-9a-d]+)$', #disk1.mkv
+ '[ _\.-]+cd[ _\.-]*([0-9a-d]+)', #*cd1
+ '[ _\.-]+dvd[ _\.-]*([0-9a-d]+)', #*dvd1
+ '[ _\.-]+part[ _\.-]*([0-9a-d]+)', #*part1
+ '[ _\.-]+dis[ck][ _\.-]*([0-9a-d]+)', #*disk1
+ 'cd[ _\.-]*([0-9a-d]+)$', #cd1.ext
+ 'dvd[ _\.-]*([0-9a-d]+)$', #dvd1.ext
+ 'part[ _\.-]*([0-9a-d]+)$', #part1.mkv
+ 'dis[ck][ _\.-]*([0-9a-d]+)$', #disk1.mkv
'()[ _\.-]+([0-9]*[abcd]+)(\.....?)$',
'([a-z])([0-9]+)(\.....?)$',
- '()([ab])(\.....?)$' #*a.mkv
+ '()([ab])(\.....?)$' #*a.mkv
]
cp_imdb = '(.cp.(?Ptt[0-9{7}]+).)'
@@ -263,7 +263,7 @@ class Scanner(Plugin):
delete_identifiers.append(identifier)
# Remove the found files from the leftover stack
- leftovers = leftovers - set([ff])
+ leftovers -= leftovers - set([ff])
# Break if CP wants to shut down
if self.shuttingDown():
@@ -445,7 +445,7 @@ class Scanner(Plugin):
files = list(group['files']['movie'])
for cur_file in files:
- if not self.filesizeBetween(cur_file, self.file_sizes['movie']): continue # Ignore smaller files
+ if not self.filesizeBetween(cur_file, self.file_sizes['movie']): continue # Ignore smaller files
meta = self.getMeta(cur_file)
@@ -727,7 +727,9 @@ class Scanner(Plugin):
if is_sample: log.debug('Is sample file: %s', filename)
return is_sample
- def filesizeBetween(self, file, file_size = []):
+ def filesizeBetween(self, file, file_size = None):
+ if not file_size: file_size = []
+
try:
return (file_size.get('min', 0) * 1048576) < os.path.getsize(file) < (file_size.get('max', 100000) * 1048576)
except:
@@ -875,7 +877,7 @@ class Scanner(Plugin):
except:
pass
- if not cp_guess: # Split name on multiple spaces
+ if not cp_guess: # Split name on multiple spaces
try:
movie_name = cleaned.split(' ').pop(0).strip()
cp_guess = {
diff --git a/couchpotato/core/plugins/score/__init__.py b/couchpotato/core/plugins/score/__init__.py
index 2c367f8..a960081 100644
--- a/couchpotato/core/plugins/score/__init__.py
+++ b/couchpotato/core/plugins/score/__init__.py
@@ -1,5 +1,6 @@
from .main import Score
+
def start():
return Score()
diff --git a/couchpotato/core/plugins/score/scores.py b/couchpotato/core/plugins/score/scores.py
index 895f5fc..c1f5123 100644
--- a/couchpotato/core/plugins/score/scores.py
+++ b/couchpotato/core/plugins/score/scores.py
@@ -51,6 +51,7 @@ def nameScore(name, year, preferred_words):
return score
+
def nameRatioScore(nzb_name, movie_name):
nzb_words = re.split('\W+', fireEvent('scanner.create_file_identifier', nzb_name, single = True))
movie_words = re.split('\W+', simplifyString(movie_name))
diff --git a/couchpotato/core/plugins/status/__init__.py b/couchpotato/core/plugins/status/__init__.py
index fb5b4cc..204fbee 100644
--- a/couchpotato/core/plugins/status/__init__.py
+++ b/couchpotato/core/plugins/status/__init__.py
@@ -1,5 +1,6 @@
from .main import StatusPlugin
+
def start():
return StatusPlugin()
diff --git a/couchpotato/core/plugins/status/main.py b/couchpotato/core/plugins/status/main.py
index b3b37bd..ad25d3c 100644
--- a/couchpotato/core/plugins/status/main.py
+++ b/couchpotato/core/plugins/status/main.py
@@ -33,7 +33,7 @@ class StatusPlugin(Plugin):
addEvent('status.get_by_id', self.getById)
addEvent('status.all', self.all)
addEvent('app.initialize', self.fill)
- addEvent('app.load', self.all) # Cache all statuses
+ addEvent('app.load', self.all) # Cache all statuses
addApiView('status.list', self.list, docs = {
'desc': 'Check for available update',
diff --git a/couchpotato/core/plugins/subtitle/__init__.py b/couchpotato/core/plugins/subtitle/__init__.py
index fcff4cd..59847ae 100644
--- a/couchpotato/core/plugins/subtitle/__init__.py
+++ b/couchpotato/core/plugins/subtitle/__init__.py
@@ -1,5 +1,6 @@
from .main import Subtitle
+
def start():
return Subtitle()
diff --git a/couchpotato/core/plugins/trailer/__init__.py b/couchpotato/core/plugins/trailer/__init__.py
index d8496b3..e7a6d26 100644
--- a/couchpotato/core/plugins/trailer/__init__.py
+++ b/couchpotato/core/plugins/trailer/__init__.py
@@ -1,5 +1,6 @@
from .main import Trailer
+
def start():
return Trailer()
diff --git a/couchpotato/core/plugins/trailer/main.py b/couchpotato/core/plugins/trailer/main.py
index e27e3f9..ba04005 100644
--- a/couchpotato/core/plugins/trailer/main.py
+++ b/couchpotato/core/plugins/trailer/main.py
@@ -28,7 +28,7 @@ class Trailer(Plugin):
destination = os.path.join(group['destination_dir'], filename)
if not os.path.isfile(destination):
trailer_file = fireEvent('file.download', url = trailer, dest = destination, urlopen_kwargs = {'headers': {'User-Agent': 'Quicktime'}}, single = True)
- if os.path.getsize(trailer_file) < (1024 * 1024): # Don't trust small trailers (1MB), try next one
+ if os.path.getsize(trailer_file) < (1024 * 1024): # Don't trust small trailers (1MB), try next one
os.unlink(trailer_file)
continue
else:
diff --git a/couchpotato/core/plugins/userscript/__init__.py b/couchpotato/core/plugins/userscript/__init__.py
index 5df5a80..184f5d7 100644
--- a/couchpotato/core/plugins/userscript/__init__.py
+++ b/couchpotato/core/plugins/userscript/__init__.py
@@ -1,5 +1,6 @@
from .main import Userscript
+
def start():
return Userscript()
diff --git a/couchpotato/core/plugins/userscript/main.py b/couchpotato/core/plugins/userscript/main.py
index 1e220d6..113c035 100644
--- a/couchpotato/core/plugins/userscript/main.py
+++ b/couchpotato/core/plugins/userscript/main.py
@@ -42,7 +42,7 @@ class Userscript(Plugin):
'excludes': fireEvent('userscript.get_excludes', merge = True),
}
- def getUserScript(self, route, **kwargs):
+ def getUserScript(self, script_route, **kwargs):
klass = self
@@ -63,8 +63,7 @@ class Userscript(Plugin):
self.redirect(Env.get('api_base') + 'file.cache/couchpotato.user.js')
- Env.get('app').add_handlers(".*$", [('%s%s' % (Env.get('api_base'), route), UserscriptHandler)])
-
+ Env.get('app').add_handlers(".*$", [('%s%s' % (Env.get('api_base'), script_route), UserscriptHandler)])
def getVersion(self):
diff --git a/couchpotato/core/plugins/wizard/__init__.py b/couchpotato/core/plugins/wizard/__init__.py
index 7887647..eda6f25 100644
--- a/couchpotato/core/plugins/wizard/__init__.py
+++ b/couchpotato/core/plugins/wizard/__init__.py
@@ -1,5 +1,6 @@
from .main import Wizard
+
def start():
return Wizard()
diff --git a/couchpotato/core/providers/automation/bluray/__init__.py b/couchpotato/core/providers/automation/bluray/__init__.py
index ed27005..519a711 100644
--- a/couchpotato/core/providers/automation/bluray/__init__.py
+++ b/couchpotato/core/providers/automation/bluray/__init__.py
@@ -1,5 +1,6 @@
from .main import Bluray
+
def start():
return Bluray()
diff --git a/couchpotato/core/providers/automation/bluray/main.py b/couchpotato/core/providers/automation/bluray/main.py
index d98557e..ddd7b8a 100644
--- a/couchpotato/core/providers/automation/bluray/main.py
+++ b/couchpotato/core/providers/automation/bluray/main.py
@@ -21,7 +21,7 @@ class Bluray(Automation, RSS):
page = 0
while True:
- page = page + 1
+ page += 1
url = self.backlog_url % page
data = self.getHTMLData(url)
@@ -37,7 +37,7 @@ class Bluray(Automation, RSS):
name = table.h3.get_text().lower().split('blu-ray')[0].strip()
year = table.small.get_text().split('|')[1].strip()
- if not name.find('/') == -1: # make sure it is not a double movie release
+ if not name.find('/') == -1: # make sure it is not a double movie release
continue
if tryInt(year) < self.getMinimal('year'):
diff --git a/couchpotato/core/providers/automation/cp/__init__.py b/couchpotato/core/providers/automation/cp/__init__.py
index a4b55a8..6b2163b 100644
--- a/couchpotato/core/providers/automation/cp/__init__.py
+++ b/couchpotato/core/providers/automation/cp/__init__.py
@@ -1,5 +1,6 @@
from .main import CP
+
def start():
return CP()
diff --git a/couchpotato/core/providers/automation/flixster/__init__.py b/couchpotato/core/providers/automation/flixster/__init__.py
index 1c6c459..71bd83c 100644
--- a/couchpotato/core/providers/automation/flixster/__init__.py
+++ b/couchpotato/core/providers/automation/flixster/__init__.py
@@ -1,5 +1,6 @@
from .main import Flixster
+
def start():
return Flixster()
diff --git a/couchpotato/core/providers/automation/flixster/main.py b/couchpotato/core/providers/automation/flixster/main.py
index 7fd2f71..f07ecd6 100644
--- a/couchpotato/core/providers/automation/flixster/main.py
+++ b/couchpotato/core/providers/automation/flixster/main.py
@@ -42,6 +42,9 @@ class Flixster(Automation):
data = self.getJsonData(self.url % user_id, decode_from = 'iso-8859-1')
for movie in data:
- movies.append({'title': movie['movie']['title'], 'year': movie['movie']['year'] })
+ movies.append({
+ 'title': movie['movie']['title'],
+ 'year': movie['movie']['year']
+ })
return movies
diff --git a/couchpotato/core/providers/automation/goodfilms/__init__.py b/couchpotato/core/providers/automation/goodfilms/__init__.py
index 795e21d..e04ccd0 100644
--- a/couchpotato/core/providers/automation/goodfilms/__init__.py
+++ b/couchpotato/core/providers/automation/goodfilms/__init__.py
@@ -1,5 +1,6 @@
from .main import Goodfilms
+
def start():
return Goodfilms()
@@ -25,4 +26,4 @@ config = [{
],
},
],
-}]
\ No newline at end of file
+}]
diff --git a/couchpotato/core/providers/automation/goodfilms/main.py b/couchpotato/core/providers/automation/goodfilms/main.py
index e112561..c4a7bd9 100644
--- a/couchpotato/core/providers/automation/goodfilms/main.py
+++ b/couchpotato/core/providers/automation/goodfilms/main.py
@@ -35,9 +35,12 @@ class Goodfilms(Automation):
data = self.getHTMLData(url)
soup = BeautifulSoup(data)
- this_watch_list = soup.find_all('div', attrs = { 'class': 'movie', 'data-film-title': True })
+ this_watch_list = soup.find_all('div', attrs = {
+ 'class': 'movie',
+ 'data-film-title': True
+ })
- if not this_watch_list: # No Movies
+ if not this_watch_list: # No Movies
break
for movie in this_watch_list:
diff --git a/couchpotato/core/providers/automation/imdb/__init__.py b/couchpotato/core/providers/automation/imdb/__init__.py
index 39bbef0..ce2ea5e 100644
--- a/couchpotato/core/providers/automation/imdb/__init__.py
+++ b/couchpotato/core/providers/automation/imdb/__init__.py
@@ -1,5 +1,6 @@
from .main import IMDB
+
def start():
return IMDB()
diff --git a/couchpotato/core/providers/automation/itunes/__init__.py b/couchpotato/core/providers/automation/itunes/__init__.py
index cc5dddc..13526f4 100644
--- a/couchpotato/core/providers/automation/itunes/__init__.py
+++ b/couchpotato/core/providers/automation/itunes/__init__.py
@@ -1,5 +1,6 @@
from .main import ITunes
+
def start():
return ITunes()
diff --git a/couchpotato/core/providers/automation/itunes/main.py b/couchpotato/core/providers/automation/itunes/main.py
index eb68e34..7676324 100644
--- a/couchpotato/core/providers/automation/itunes/main.py
+++ b/couchpotato/core/providers/automation/itunes/main.py
@@ -22,7 +22,7 @@ class ITunes(Automation, RSS):
urls = splitString(self.conf('automation_urls'))
namespace = 'http://www.w3.org/2005/Atom'
- namespaceIM = 'http://itunes.apple.com/rss'
+ namespace_im = 'http://itunes.apple.com/rss'
index = -1
for url in urls:
@@ -42,10 +42,10 @@ class ITunes(Automation, RSS):
rss_movies = self.getElements(data, entry_tag)
for movie in rss_movies:
- name_tag = str(QName(namespaceIM, 'name'))
+ name_tag = str(QName(namespace_im, 'name'))
name = self.getTextElement(movie, name_tag)
- releaseDate_tag = str(QName(namespaceIM, 'releaseDate'))
+ releaseDate_tag = str(QName(namespace_im, 'releaseDate'))
releaseDateText = self.getTextElement(movie, releaseDate_tag)
year = datetime.datetime.strptime(releaseDateText, '%Y-%m-%dT00:00:00-07:00').strftime("%Y")
diff --git a/couchpotato/core/providers/automation/kinepolis/__init__.py b/couchpotato/core/providers/automation/kinepolis/__init__.py
index 24bd4eb..cc4c570 100644
--- a/couchpotato/core/providers/automation/kinepolis/__init__.py
+++ b/couchpotato/core/providers/automation/kinepolis/__init__.py
@@ -1,5 +1,6 @@
from .main import Kinepolis
+
def start():
return Kinepolis()
diff --git a/couchpotato/core/providers/automation/letterboxd/__init__.py b/couchpotato/core/providers/automation/letterboxd/__init__.py
index f2b8486..88bfe6a 100644
--- a/couchpotato/core/providers/automation/letterboxd/__init__.py
+++ b/couchpotato/core/providers/automation/letterboxd/__init__.py
@@ -1,5 +1,6 @@
from .main import Letterboxd
+
def start():
return Letterboxd()
diff --git a/couchpotato/core/providers/automation/letterboxd/main.py b/couchpotato/core/providers/automation/letterboxd/main.py
index 1f106dd..ca457a2 100644
--- a/couchpotato/core/providers/automation/letterboxd/main.py
+++ b/couchpotato/core/providers/automation/letterboxd/main.py
@@ -44,7 +44,7 @@ class Letterboxd(Automation):
soup = BeautifulSoup(self.getHTMLData(self.url % username))
- for movie in soup.find_all('a', attrs = { 'class': 'frame' }):
+ for movie in soup.find_all('a', attrs = {'class': 'frame'}):
match = filter(None, self.pattern.split(movie['title']))
movies.append({'title': match[0], 'year': match[1] })
diff --git a/couchpotato/core/providers/automation/moviemeter/__init__.py b/couchpotato/core/providers/automation/moviemeter/__init__.py
index aff5d09..0e9a4ed 100644
--- a/couchpotato/core/providers/automation/moviemeter/__init__.py
+++ b/couchpotato/core/providers/automation/moviemeter/__init__.py
@@ -1,5 +1,6 @@
from .main import Moviemeter
+
def start():
return Moviemeter()
diff --git a/couchpotato/core/providers/automation/movies_io/__init__.py b/couchpotato/core/providers/automation/movies_io/__init__.py
index 9b28093..0361223 100644
--- a/couchpotato/core/providers/automation/movies_io/__init__.py
+++ b/couchpotato/core/providers/automation/movies_io/__init__.py
@@ -1,5 +1,6 @@
from .main import MoviesIO
+
def start():
return MoviesIO()
diff --git a/couchpotato/core/providers/automation/rottentomatoes/__init__.py b/couchpotato/core/providers/automation/rottentomatoes/__init__.py
index 4675fac..1d3026d 100644
--- a/couchpotato/core/providers/automation/rottentomatoes/__init__.py
+++ b/couchpotato/core/providers/automation/rottentomatoes/__init__.py
@@ -1,5 +1,6 @@
from .main import Rottentomatoes
+
def start():
return Rottentomatoes()
diff --git a/couchpotato/core/providers/automation/rottentomatoes/main.py b/couchpotato/core/providers/automation/rottentomatoes/main.py
index 6961170..c873a8e 100644
--- a/couchpotato/core/providers/automation/rottentomatoes/main.py
+++ b/couchpotato/core/providers/automation/rottentomatoes/main.py
@@ -8,6 +8,7 @@ import re
log = CPLog(__name__)
+
class Rottentomatoes(Automation, RSS):
interval = 1800
diff --git a/couchpotato/core/providers/automation/trakt/__init__.py b/couchpotato/core/providers/automation/trakt/__init__.py
index cbaaece..6ae2806 100644
--- a/couchpotato/core/providers/automation/trakt/__init__.py
+++ b/couchpotato/core/providers/automation/trakt/__init__.py
@@ -1,5 +1,6 @@
from .main import Trakt
+
def start():
return Trakt()
diff --git a/couchpotato/core/providers/base.py b/couchpotato/core/providers/base.py
index 89967df..1aceac4 100644
--- a/couchpotato/core/providers/base.py
+++ b/couchpotato/core/providers/base.py
@@ -14,6 +14,7 @@ import xml.etree.ElementTree as XMLTree
log = CPLog(__name__)
+
class MultiProvider(Plugin):
def __init__(self):
@@ -36,8 +37,8 @@ class MultiProvider(Plugin):
class Provider(Plugin):
- type = None # movie, show, subtitle, trailer, ...
- http_time_between_calls = 10 # Default timeout for url requests
+ type = None # movie, show, subtitle, trailer, ...
+ http_time_between_calls = 10 # Default timeout for url requests
last_available_check = {}
is_available = {}
@@ -100,15 +101,15 @@ class Provider(Plugin):
class YarrProvider(Provider):
- protocol = None # nzb, torrent, torrent_magnet
+ protocol = None # nzb, torrent, torrent_magnet
type = 'movie'
cat_ids = {}
cat_backup_id = None
- sizeGb = ['gb', 'gib']
- sizeMb = ['mb', 'mib']
- sizeKb = ['kb', 'kib']
+ size_gb = ['gb', 'gib']
+ size_mb = ['mb', 'mib']
+ size_kb = ['kb', 'kib']
last_login_check = None
@@ -223,19 +224,19 @@ class YarrProvider(Provider):
def parseSize(self, size):
- sizeRaw = size.lower()
+ size_raw = size.lower()
size = tryFloat(re.sub(r'[^0-9.]', '', size).strip())
- for s in self.sizeGb:
- if s in sizeRaw:
+ for s in self.size_gb:
+ if s in size_raw:
return size * 1024
- for s in self.sizeMb:
- if s in sizeRaw:
+ for s in self.size_mb:
+ if s in size_raw:
return size
- for s in self.sizeKb:
- if s in sizeRaw:
+ for s in self.size_kb:
+ if s in size_raw:
return size / 1024
return 0
@@ -279,7 +280,7 @@ class ResultList(list):
new_result = self.fillResult(result)
is_correct = fireEvent('searcher.correct_release', new_result, self.media, self.quality,
- imdb_results = self.kwargs.get('imdb_results', False), single = True)
+ imdb_results = self.kwargs.get('imdb_results', False), single = True)
if is_correct and new_result['id'] not in self.result_ids:
is_correct_weight = float(is_correct)
diff --git a/couchpotato/core/providers/info/_modifier/__init__.py b/couchpotato/core/providers/info/_modifier/__init__.py
index 3bdf5e0..9dfab70 100644
--- a/couchpotato/core/providers/info/_modifier/__init__.py
+++ b/couchpotato/core/providers/info/_modifier/__init__.py
@@ -1,7 +1,7 @@
from .main import MovieResultModifier
-def start():
+def start():
return MovieResultModifier()
config = []
diff --git a/couchpotato/core/providers/info/_modifier/main.py b/couchpotato/core/providers/info/_modifier/main.py
index c7e3a5e..88d4381 100644
--- a/couchpotato/core/providers/info/_modifier/main.py
+++ b/couchpotato/core/providers/info/_modifier/main.py
@@ -44,13 +44,13 @@ class MovieResultModifier(Plugin):
new_results = {}
for r in results:
type_name = r.get('type', 'movie') + 's'
- if not new_results.has_key(type_name):
+ if type_name not in new_results:
new_results[type_name] = []
new_results[type_name].append(r)
# Combine movies, needs a cleaner way..
- if new_results.has_key('movies'):
+ if 'movies' in new_results:
new_results['movies'] = self.combineOnIMDB(new_results['movies'])
return new_results
diff --git a/couchpotato/core/providers/info/couchpotatoapi/__init__.py b/couchpotato/core/providers/info/couchpotatoapi/__init__.py
index 37d9eca..196dde6 100644
--- a/couchpotato/core/providers/info/couchpotatoapi/__init__.py
+++ b/couchpotato/core/providers/info/couchpotatoapi/__init__.py
@@ -1,5 +1,6 @@
from .main import CouchPotatoApi
+
def start():
return CouchPotatoApi()
diff --git a/couchpotato/core/providers/info/couchpotatoapi/main.py b/couchpotato/core/providers/info/couchpotatoapi/main.py
index cf51281..e5efbcf 100644
--- a/couchpotato/core/providers/info/couchpotatoapi/main.py
+++ b/couchpotato/core/providers/info/couchpotatoapi/main.py
@@ -110,5 +110,5 @@ class CouchPotatoApi(MovieProvider):
'X-CP-Version': fireEvent('app.version', single = True),
'X-CP-API': self.api_version,
'X-CP-Time': time.time(),
- 'X-CP-Identifier': '+%s' % Env.setting('api_key', 'core')[:10], # Use first 10 as identifier, so we don't need to use IP address in api stats
+ 'X-CP-Identifier': '+%s' % Env.setting('api_key', 'core')[:10], # Use first 10 as identifier, so we don't need to use IP address in api stats
}
diff --git a/couchpotato/core/providers/info/omdbapi/__init__.py b/couchpotato/core/providers/info/omdbapi/__init__.py
index 765662e..b7ea393 100644
--- a/couchpotato/core/providers/info/omdbapi/__init__.py
+++ b/couchpotato/core/providers/info/omdbapi/__init__.py
@@ -1,5 +1,6 @@
from .main import OMDBAPI
+
def start():
return OMDBAPI()
diff --git a/couchpotato/core/providers/info/themoviedb/__init__.py b/couchpotato/core/providers/info/themoviedb/__init__.py
index 66ac536..b981950 100644
--- a/couchpotato/core/providers/info/themoviedb/__init__.py
+++ b/couchpotato/core/providers/info/themoviedb/__init__.py
@@ -1,5 +1,6 @@
from .main import TheMovieDb
+
def start():
return TheMovieDb()
diff --git a/couchpotato/core/providers/info/themoviedb/main.py b/couchpotato/core/providers/info/themoviedb/main.py
index fa6896b..d2f4893 100644
--- a/couchpotato/core/providers/info/themoviedb/main.py
+++ b/couchpotato/core/providers/info/themoviedb/main.py
@@ -56,7 +56,7 @@ class TheMovieDb(MovieProvider):
self.setCache(cache_key, results)
return results
- except SyntaxError, e:
+ except SyntaxError as e:
log.error('Failed to parse XML response: %s', e)
return False
diff --git a/couchpotato/core/providers/metadata/wmc/__init__.py b/couchpotato/core/providers/metadata/wmc/__init__.py
index 290436c..167a24d 100644
--- a/couchpotato/core/providers/metadata/wmc/__init__.py
+++ b/couchpotato/core/providers/metadata/wmc/__init__.py
@@ -1,5 +1,6 @@
from .main import WindowsMediaCenter
+
def start():
return WindowsMediaCenter()
diff --git a/couchpotato/core/providers/metadata/wmc/main.py b/couchpotato/core/providers/metadata/wmc/main.py
index 8925891..f84897b 100644
--- a/couchpotato/core/providers/metadata/wmc/main.py
+++ b/couchpotato/core/providers/metadata/wmc/main.py
@@ -1,6 +1,7 @@
from couchpotato.core.providers.metadata.base import MetaDataBase
import os
+
class WindowsMediaCenter(MetaDataBase):
def getThumbnailName(self, name, root):
diff --git a/couchpotato/core/providers/metadata/xbmc/__init__.py b/couchpotato/core/providers/metadata/xbmc/__init__.py
index ea426db..deb5c90 100644
--- a/couchpotato/core/providers/metadata/xbmc/__init__.py
+++ b/couchpotato/core/providers/metadata/xbmc/__init__.py
@@ -1,5 +1,6 @@
from .main import XBMC
+
def start():
return XBMC()
diff --git a/couchpotato/core/providers/metadata/xbmc/main.py b/couchpotato/core/providers/metadata/xbmc/main.py
index 93e717f..267b282 100644
--- a/couchpotato/core/providers/metadata/xbmc/main.py
+++ b/couchpotato/core/providers/metadata/xbmc/main.py
@@ -132,7 +132,7 @@ class XBMC(MetaDataBase):
# Add trailer if found
trailer_found = False
if data.get('renamed_files'):
- for filename in data.get('renamed_files'):
+ for filename in data.get('renamed_files'):
if 'trailer' in filename:
trailer = SubElement(nfoxml, 'trailer')
trailer.text = toUnicode(filename)
diff --git a/couchpotato/core/providers/nzb/binsearch/__init__.py b/couchpotato/core/providers/nzb/binsearch/__init__.py
index 1cfb0b7..c80ee6d 100644
--- a/couchpotato/core/providers/nzb/binsearch/__init__.py
+++ b/couchpotato/core/providers/nzb/binsearch/__init__.py
@@ -1,5 +1,6 @@
from .main import BinSearch
+
def start():
return BinSearch()
diff --git a/couchpotato/core/providers/nzb/binsearch/main.py b/couchpotato/core/providers/nzb/binsearch/main.py
index 54cb1ab..c54dd43 100644
--- a/couchpotato/core/providers/nzb/binsearch/main.py
+++ b/couchpotato/core/providers/nzb/binsearch/main.py
@@ -18,7 +18,7 @@ class BinSearch(NZBProvider):
'search': 'https://www.binsearch.info/index.php?%s',
}
- http_time_between_calls = 4 # Seconds
+ http_time_between_calls = 4 # Seconds
def _search(self, movie, quality, results):
diff --git a/couchpotato/core/providers/nzb/newznab/__init__.py b/couchpotato/core/providers/nzb/newznab/__init__.py
index e0bf570..97f1cfa 100644
--- a/couchpotato/core/providers/nzb/newznab/__init__.py
+++ b/couchpotato/core/providers/nzb/newznab/__init__.py
@@ -1,5 +1,6 @@
from .main import Newznab
+
def start():
return Newznab()
diff --git a/couchpotato/core/providers/nzb/newznab/main.py b/couchpotato/core/providers/nzb/newznab/main.py
index 49c3ae9..deadaa1 100644
--- a/couchpotato/core/providers/nzb/newznab/main.py
+++ b/couchpotato/core/providers/nzb/newznab/main.py
@@ -25,7 +25,7 @@ class Newznab(NZBProvider, RSS):
limits_reached = {}
- http_time_between_calls = 1 # Seconds
+ http_time_between_calls = 1 # Seconds
def search(self, movie, quality):
hosts = self.getHosts()
@@ -180,7 +180,7 @@ class Newznab(NZBProvider, RSS):
data = self.urlopen(finalurl, show_error = False)
self.limits_reached[host] = False
return data
- except HTTPError, e:
+ except HTTPError as e:
if e.code == 503:
response = e.read().lower()
if 'maximum api' in response or 'download limit' in response:
diff --git a/couchpotato/core/providers/nzb/nzbclub/__init__.py b/couchpotato/core/providers/nzb/nzbclub/__init__.py
index 95eeea1..02a6940 100644
--- a/couchpotato/core/providers/nzb/nzbclub/__init__.py
+++ b/couchpotato/core/providers/nzb/nzbclub/__init__.py
@@ -1,5 +1,6 @@
from .main import NZBClub
+
def start():
return NZBClub()
diff --git a/couchpotato/core/providers/nzb/nzbclub/main.py b/couchpotato/core/providers/nzb/nzbclub/main.py
index 59382df..778cdbc 100644
--- a/couchpotato/core/providers/nzb/nzbclub/main.py
+++ b/couchpotato/core/providers/nzb/nzbclub/main.py
@@ -16,7 +16,7 @@ class NZBClub(NZBProvider, RSS):
'search': 'http://www.nzbclub.com/nzbfeed.aspx?%s',
}
- http_time_between_calls = 4 #seconds
+ http_time_between_calls = 4 #seconds
def _searchOnTitle(self, title, movie, quality, results):
diff --git a/couchpotato/core/providers/nzb/nzbindex/__init__.py b/couchpotato/core/providers/nzb/nzbindex/__init__.py
index 47461e6..acb53e1 100644
--- a/couchpotato/core/providers/nzb/nzbindex/__init__.py
+++ b/couchpotato/core/providers/nzb/nzbindex/__init__.py
@@ -1,5 +1,6 @@
from .main import NzbIndex
+
def start():
return NzbIndex()
diff --git a/couchpotato/core/providers/nzb/nzbindex/main.py b/couchpotato/core/providers/nzb/nzbindex/main.py
index 17b87fa..a143c19 100644
--- a/couchpotato/core/providers/nzb/nzbindex/main.py
+++ b/couchpotato/core/providers/nzb/nzbindex/main.py
@@ -19,7 +19,7 @@ class NzbIndex(NZBProvider, RSS):
'search': 'https://www.nzbindex.com/rss/?%s',
}
- http_time_between_calls = 1 # Seconds
+ http_time_between_calls = 1 # Seconds
def _searchOnTitle(self, title, movie, quality, results):
diff --git a/couchpotato/core/providers/nzb/omgwtfnzbs/__init__.py b/couchpotato/core/providers/nzb/omgwtfnzbs/__init__.py
index 933aff3..2f3990d 100644
--- a/couchpotato/core/providers/nzb/omgwtfnzbs/__init__.py
+++ b/couchpotato/core/providers/nzb/omgwtfnzbs/__init__.py
@@ -1,5 +1,6 @@
from .main import OMGWTFNZBs
+
def start():
return OMGWTFNZBs()
diff --git a/couchpotato/core/providers/nzb/omgwtfnzbs/main.py b/couchpotato/core/providers/nzb/omgwtfnzbs/main.py
index 8cc4a3e..9392575 100644
--- a/couchpotato/core/providers/nzb/omgwtfnzbs/main.py
+++ b/couchpotato/core/providers/nzb/omgwtfnzbs/main.py
@@ -18,7 +18,7 @@ class OMGWTFNZBs(NZBProvider, RSS):
'detail_url': 'https://omgwtfnzbs.org/details.php?id=%s',
}
- http_time_between_calls = 1 #seconds
+ http_time_between_calls = 1 #seconds
cat_ids = [
([15], ['dvdrip']),
diff --git a/couchpotato/core/providers/torrent/awesomehd/__init__.py b/couchpotato/core/providers/torrent/awesomehd/__init__.py
index de6a214..6f07670 100644
--- a/couchpotato/core/providers/torrent/awesomehd/__init__.py
+++ b/couchpotato/core/providers/torrent/awesomehd/__init__.py
@@ -1,5 +1,6 @@
from .main import AwesomeHD
+
def start():
return AwesomeHD()
diff --git a/couchpotato/core/providers/torrent/awesomehd/main.py b/couchpotato/core/providers/torrent/awesomehd/main.py
index 79482f2..ca6a30d 100644
--- a/couchpotato/core/providers/torrent/awesomehd/main.py
+++ b/couchpotato/core/providers/torrent/awesomehd/main.py
@@ -11,10 +11,10 @@ log = CPLog(__name__)
class AwesomeHD(TorrentProvider):
urls = {
- 'test' : 'https://awesome-hd.net/',
- 'detail' : 'https://awesome-hd.net/torrents.php?torrentid=%s',
- 'search' : 'https://awesome-hd.net/searchapi.php?action=imdbsearch&passkey=%s&imdb=%s&internal=%s',
- 'download' : 'https://awesome-hd.net/torrents.php?action=download&id=%s&authkey=%s&torrent_pass=%s',
+ 'test': 'https://awesome-hd.net/',
+ 'detail': 'https://awesome-hd.net/torrents.php?torrentid=%s',
+ 'search': 'https://awesome-hd.net/searchapi.php?action=imdbsearch&passkey=%s&imdb=%s&internal=%s',
+ 'download': 'https://awesome-hd.net/torrents.php?action=download&id=%s&authkey=%s&torrent_pass=%s',
}
http_time_between_calls = 1
diff --git a/couchpotato/core/providers/torrent/base.py b/couchpotato/core/providers/torrent/base.py
index c16e6c5..02cc549 100644
--- a/couchpotato/core/providers/torrent/base.py
+++ b/couchpotato/core/providers/torrent/base.py
@@ -14,22 +14,6 @@ class TorrentProvider(YarrProvider):
proxy_domain = None
proxy_list = []
- def imdbMatch(self, url, imdbId):
- if getImdb(url) == imdbId:
- return True
-
- if url[:4] == 'http':
- try:
- cache_key = md5(url)
- data = self.getCache(cache_key, url)
- except IOError:
- log.error('Failed to open %s.', url)
- return False
-
- return getImdb(data) == imdbId
-
- return False
-
def getDomain(self, url = ''):
forced_domain = self.conf('domain')
@@ -63,9 +47,10 @@ class TorrentProvider(YarrProvider):
return cleanHost(self.proxy_domain).rstrip('/') + url
- def correctProxy(self):
+ def correctProxy(self, data):
return True
+
class TorrentMagnetProvider(TorrentProvider):
protocol = 'torrent_magnet'
diff --git a/couchpotato/core/providers/torrent/bithdtv/__init__.py b/couchpotato/core/providers/torrent/bithdtv/__init__.py
index 8c6f97a..ffc5363 100644
--- a/couchpotato/core/providers/torrent/bithdtv/__init__.py
+++ b/couchpotato/core/providers/torrent/bithdtv/__init__.py
@@ -1,5 +1,6 @@
from .main import BiTHDTV
+
def start():
return BiTHDTV()
diff --git a/couchpotato/core/providers/torrent/bithdtv/main.py b/couchpotato/core/providers/torrent/bithdtv/main.py
index 0045fb8..90117de 100644
--- a/couchpotato/core/providers/torrent/bithdtv/main.py
+++ b/couchpotato/core/providers/torrent/bithdtv/main.py
@@ -7,14 +7,15 @@ import traceback
log = CPLog(__name__)
+
class BiTHDTV(TorrentProvider):
urls = {
- 'test' : 'http://www.bit-hdtv.com/',
- 'login' : 'http://www.bit-hdtv.com/takelogin.php',
+ 'test': 'http://www.bit-hdtv.com/',
+ 'login': 'http://www.bit-hdtv.com/takelogin.php',
'login_check': 'http://www.bit-hdtv.com/messages.php',
- 'detail' : 'http://www.bit-hdtv.com/details.php?id=%s',
- 'search' : 'http://www.bit-hdtv.com/torrents.php?',
+ 'detail': 'http://www.bit-hdtv.com/details.php?id=%s',
+ 'search': 'http://www.bit-hdtv.com/torrents.php?',
}
# Searches for movies only - BiT-HDTV's subcategory and resolution search filters appear to be broken
diff --git a/couchpotato/core/providers/torrent/bitsoup/__init__.py b/couchpotato/core/providers/torrent/bitsoup/__init__.py
index a36ab08..da07cc3 100644
--- a/couchpotato/core/providers/torrent/bitsoup/__init__.py
+++ b/couchpotato/core/providers/torrent/bitsoup/__init__.py
@@ -1,5 +1,6 @@
from .main import Bitsoup
+
def start():
return Bitsoup()
diff --git a/couchpotato/core/providers/torrent/bitsoup/main.py b/couchpotato/core/providers/torrent/bitsoup/main.py
index 0c6c957..a709c5c 100644
--- a/couchpotato/core/providers/torrent/bitsoup/main.py
+++ b/couchpotato/core/providers/torrent/bitsoup/main.py
@@ -12,7 +12,7 @@ class Bitsoup(TorrentProvider):
urls = {
'test': 'https://www.bitsoup.me/',
- 'login' : 'https://www.bitsoup.me/takelogin.php',
+ 'login': 'https://www.bitsoup.me/takelogin.php',
'login_check': 'https://www.bitsoup.me/my.php',
'search': 'https://www.bitsoup.me/browse.php?',
'baseurl': 'https://www.bitsoup.me/%s',
diff --git a/couchpotato/core/providers/torrent/hdbits/__init__.py b/couchpotato/core/providers/torrent/hdbits/__init__.py
index 07ea95d..f087379 100644
--- a/couchpotato/core/providers/torrent/hdbits/__init__.py
+++ b/couchpotato/core/providers/torrent/hdbits/__init__.py
@@ -1,5 +1,6 @@
from .main import HDBits
+
def start():
return HDBits()
diff --git a/couchpotato/core/providers/torrent/hdbits/main.py b/couchpotato/core/providers/torrent/hdbits/main.py
index 1d3516f..1ecc97e 100644
--- a/couchpotato/core/providers/torrent/hdbits/main.py
+++ b/couchpotato/core/providers/torrent/hdbits/main.py
@@ -10,11 +10,11 @@ log = CPLog(__name__)
class HDBits(TorrentProvider):
urls = {
- 'test' : 'https://hdbits.org/',
- 'login' : 'https://hdbits.org/login/doLogin/',
- 'detail' : 'https://hdbits.org/details.php?id=%s&source=browse',
- 'search' : 'https://hdbits.org/json_search.php?imdb=%s',
- 'download' : 'https://hdbits.org/download.php/%s.torrent?id=%s&passkey=%s&source=details.browse',
+ 'test': 'https://hdbits.org/',
+ 'login': 'https://hdbits.org/login/doLogin/',
+ 'detail': 'https://hdbits.org/details.php?id=%s&source=browse',
+ 'search': 'https://hdbits.org/json_search.php?imdb=%s',
+ 'download': 'https://hdbits.org/download.php/%s.torrent?id=%s&passkey=%s&source=details.browse',
'login_check': 'http://hdbits.org/inbox.php',
}
diff --git a/couchpotato/core/providers/torrent/ilovetorrents/__init__.py b/couchpotato/core/providers/torrent/ilovetorrents/__init__.py
index c6702d7..44fa353 100644
--- a/couchpotato/core/providers/torrent/ilovetorrents/__init__.py
+++ b/couchpotato/core/providers/torrent/ilovetorrents/__init__.py
@@ -1,5 +1,6 @@
from main import ILoveTorrents
+
def start():
return ILoveTorrents()
@@ -18,14 +19,14 @@ config = [{
'type': 'enabler',
'default': False
},
- {
+ {
'name': 'username',
'label': 'Username',
'type': 'string',
'default': '',
'description': 'The user name for your ILT account',
},
- {
+ {
'name': 'password',
'label': 'Password',
'type': 'password',
diff --git a/couchpotato/core/providers/torrent/ilovetorrents/main.py b/couchpotato/core/providers/torrent/ilovetorrents/main.py
index 7181016..6d56ea4 100644
--- a/couchpotato/core/providers/torrent/ilovetorrents/main.py
+++ b/couchpotato/core/providers/torrent/ilovetorrents/main.py
@@ -14,10 +14,10 @@ class ILoveTorrents(TorrentProvider):
urls = {
'download': 'http://www.ilovetorrents.me/%s',
'detail': 'http://www.ilovetorrents.me/%s',
- 'search': 'http://www.ilovetorrents.me/browse.php?search=%s&page=%s&cat=%s',
- 'test' : 'http://www.ilovetorrents.me/',
- 'login' : 'http://www.ilovetorrents.me/takelogin.php',
- 'login_check' : 'http://www.ilovetorrents.me'
+ 'search': 'http://www.ilovetorrents.me/browse.php?search=%s&page=%s&cat=%s',
+ 'test': 'http://www.ilovetorrents.me/',
+ 'login': 'http://www.ilovetorrents.me/takelogin.php',
+ 'login_check': 'http://www.ilovetorrents.me'
}
cat_ids = [
diff --git a/couchpotato/core/providers/torrent/iptorrents/__init__.py b/couchpotato/core/providers/torrent/iptorrents/__init__.py
index 6cb2dea..579d797 100644
--- a/couchpotato/core/providers/torrent/iptorrents/__init__.py
+++ b/couchpotato/core/providers/torrent/iptorrents/__init__.py
@@ -1,5 +1,6 @@
from .main import IPTorrents
+
def start():
return IPTorrents()
diff --git a/couchpotato/core/providers/torrent/iptorrents/main.py b/couchpotato/core/providers/torrent/iptorrents/main.py
index a02b97f..e29aa41 100644
--- a/couchpotato/core/providers/torrent/iptorrents/main.py
+++ b/couchpotato/core/providers/torrent/iptorrents/main.py
@@ -11,11 +11,11 @@ log = CPLog(__name__)
class IPTorrents(TorrentProvider):
urls = {
- 'test' : 'http://www.iptorrents.com/',
- 'base_url' : 'http://www.iptorrents.com',
- 'login' : 'http://www.iptorrents.com/torrents/',
+ 'test': 'http://www.iptorrents.com/',
+ 'base_url': 'http://www.iptorrents.com',
+ 'login': 'http://www.iptorrents.com/torrents/',
'login_check': 'http://www.iptorrents.com/inbox.php',
- 'search' : 'http://www.iptorrents.com/torrents/?l%d=1%s&q=%s&qf=ti&p=%d',
+ 'search': 'http://www.iptorrents.com/torrents/?l%d=1%s&q=%s&qf=ti&p=%d',
}
cat_ids = [
diff --git a/couchpotato/core/providers/torrent/kickasstorrents/__init__.py b/couchpotato/core/providers/torrent/kickasstorrents/__init__.py
index 0b79c81..ffe1040 100644
--- a/couchpotato/core/providers/torrent/kickasstorrents/__init__.py
+++ b/couchpotato/core/providers/torrent/kickasstorrents/__init__.py
@@ -1,5 +1,6 @@
from .main import KickAssTorrents
+
def start():
return KickAssTorrents()
diff --git a/couchpotato/core/providers/torrent/kickasstorrents/main.py b/couchpotato/core/providers/torrent/kickasstorrents/main.py
index 50f14ce..f96e981 100644
--- a/couchpotato/core/providers/torrent/kickasstorrents/main.py
+++ b/couchpotato/core/providers/torrent/kickasstorrents/main.py
@@ -24,7 +24,7 @@ class KickAssTorrents(TorrentMagnetProvider):
(['dvd'], ['dvdr']),
]
- http_time_between_calls = 1 #seconds
+ http_time_between_calls = 1 #seconds
cat_backup_id = None
proxy_list = [
@@ -45,7 +45,7 @@ class KickAssTorrents(TorrentMagnetProvider):
try:
html = BeautifulSoup(data)
- resultdiv = html.find('div', attrs = {'class':'tabs'})
+ resultdiv = html.find('div', attrs = {'class': 'tabs'})
for result in resultdiv.find_all('div', recursive = False):
if result.get('id').lower().strip('tab-') not in cat_ids:
continue
@@ -107,7 +107,6 @@ class KickAssTorrents(TorrentMagnetProvider):
return tryInt(age)
-
def isEnabled(self):
return super(KickAssTorrents, self).isEnabled() and self.getDomain()
diff --git a/couchpotato/core/providers/torrent/passthepopcorn/__init__.py b/couchpotato/core/providers/torrent/passthepopcorn/__init__.py
index 66b3ea7..9593c44 100644
--- a/couchpotato/core/providers/torrent/passthepopcorn/__init__.py
+++ b/couchpotato/core/providers/torrent/passthepopcorn/__init__.py
@@ -1,5 +1,6 @@
from main import PassThePopcorn
+
def start():
return PassThePopcorn()
diff --git a/couchpotato/core/providers/torrent/passthepopcorn/main.py b/couchpotato/core/providers/torrent/passthepopcorn/main.py
index 5cd3aed..48a7e2a 100644
--- a/couchpotato/core/providers/torrent/passthepopcorn/main.py
+++ b/couchpotato/core/providers/torrent/passthepopcorn/main.py
@@ -15,12 +15,12 @@ log = CPLog(__name__)
class PassThePopcorn(TorrentProvider):
urls = {
- 'domain': 'https://tls.passthepopcorn.me',
- 'detail': 'https://tls.passthepopcorn.me/torrents.php?torrentid=%s',
- 'torrent': 'https://tls.passthepopcorn.me/torrents.php',
- 'login': 'https://tls.passthepopcorn.me/ajax.php?action=login',
- 'login_check': 'https://tls.passthepopcorn.me/ajax.php?action=login',
- 'search': 'https://tls.passthepopcorn.me/search/%s/0/7/%d'
+ 'domain': 'https://tls.passthepopcorn.me',
+ 'detail': 'https://tls.passthepopcorn.me/torrents.php?torrentid=%s',
+ 'torrent': 'https://tls.passthepopcorn.me/torrents.php',
+ 'login': 'https://tls.passthepopcorn.me/ajax.php?action=login',
+ 'login_check': 'https://tls.passthepopcorn.me/ajax.php?action=login',
+ 'search': 'https://tls.passthepopcorn.me/search/%s/0/7/%d'
}
http_time_between_calls = 2
diff --git a/couchpotato/core/providers/torrent/publichd/__init__.py b/couchpotato/core/providers/torrent/publichd/__init__.py
index ace1288..3c20c51 100644
--- a/couchpotato/core/providers/torrent/publichd/__init__.py
+++ b/couchpotato/core/providers/torrent/publichd/__init__.py
@@ -1,5 +1,6 @@
from .main import PublicHD
+
def start():
return PublicHD()
diff --git a/couchpotato/core/providers/torrent/publichd/main.py b/couchpotato/core/providers/torrent/publichd/main.py
index 7b497fd..b7c32fb 100644
--- a/couchpotato/core/providers/torrent/publichd/main.py
+++ b/couchpotato/core/providers/torrent/publichd/main.py
@@ -76,7 +76,7 @@ class PublicHD(TorrentMagnetProvider):
try:
full_description = self.urlopen(item['detail_url'])
html = BeautifulSoup(full_description)
- nfo_pre = html.find('div', attrs = {'id':'torrmain'})
+ nfo_pre = html.find('div', attrs = {'id': 'torrmain'})
description = toUnicode(nfo_pre.text) if nfo_pre else ''
except:
log.error('Failed getting more info for %s', item['name'])
diff --git a/couchpotato/core/providers/torrent/sceneaccess/__init__.py b/couchpotato/core/providers/torrent/sceneaccess/__init__.py
index 4b675573..3fa5d97 100644
--- a/couchpotato/core/providers/torrent/sceneaccess/__init__.py
+++ b/couchpotato/core/providers/torrent/sceneaccess/__init__.py
@@ -1,5 +1,6 @@
from .main import SceneAccess
+
def start():
return SceneAccess()
diff --git a/couchpotato/core/providers/torrent/sceneaccess/main.py b/couchpotato/core/providers/torrent/sceneaccess/main.py
index 4113d38..a43c49b 100644
--- a/couchpotato/core/providers/torrent/sceneaccess/main.py
+++ b/couchpotato/core/providers/torrent/sceneaccess/main.py
@@ -25,7 +25,7 @@ class SceneAccess(TorrentProvider):
([8], ['dvdr']),
]
- http_time_between_calls = 1 #seconds
+ http_time_between_calls = 1 #seconds
def _search(self, movie, quality, results):
diff --git a/couchpotato/core/providers/torrent/thepiratebay/__init__.py b/couchpotato/core/providers/torrent/thepiratebay/__init__.py
index 8cf9f86..3cb35d1 100644
--- a/couchpotato/core/providers/torrent/thepiratebay/__init__.py
+++ b/couchpotato/core/providers/torrent/thepiratebay/__init__.py
@@ -1,5 +1,6 @@
from main import ThePirateBay
+
def start():
return ThePirateBay()
diff --git a/couchpotato/core/providers/torrent/thepiratebay/main.py b/couchpotato/core/providers/torrent/thepiratebay/main.py
index b967d5f..4650850 100644
--- a/couchpotato/core/providers/torrent/thepiratebay/main.py
+++ b/couchpotato/core/providers/torrent/thepiratebay/main.py
@@ -12,15 +12,15 @@ log = CPLog(__name__)
class ThePirateBay(TorrentMagnetProvider):
urls = {
- 'detail': '%s/torrent/%s',
- 'search': '%s/search/%s/%s/7/%s'
+ 'detail': '%s/torrent/%s',
+ 'search': '%s/search/%s/%s/7/%s'
}
cat_ids = [
- ([207], ['720p', '1080p']),
- ([201], ['cam', 'ts', 'dvdrip', 'tc', 'r5', 'scr']),
- ([201, 207], ['brrip']),
- ([202], ['dvdr'])
+ ([207], ['720p', '1080p']),
+ ([201], ['cam', 'ts', 'dvdrip', 'tc', 'r5', 'scr']),
+ ([201, 207], ['brrip']),
+ ([202], ['dvdr'])
]
cat_backup_id = 200
@@ -111,7 +111,7 @@ class ThePirateBay(TorrentMagnetProvider):
def getMoreInfo(self, item):
full_description = self.getCache('tpb.%s' % item['id'], item['detail_url'], cache_timeout = 25920000)
html = BeautifulSoup(full_description)
- nfo_pre = html.find('div', attrs = {'class':'nfo'})
+ nfo_pre = html.find('div', attrs = {'class': 'nfo'})
description = toUnicode(nfo_pre.text) if nfo_pre else ''
item['description'] = description
diff --git a/couchpotato/core/providers/torrent/torrentbytes/__init__.py b/couchpotato/core/providers/torrent/torrentbytes/__init__.py
index 712eac8..79dec93 100644
--- a/couchpotato/core/providers/torrent/torrentbytes/__init__.py
+++ b/couchpotato/core/providers/torrent/torrentbytes/__init__.py
@@ -1,5 +1,6 @@
from .main import TorrentBytes
+
def start():
return TorrentBytes()
diff --git a/couchpotato/core/providers/torrent/torrentbytes/main.py b/couchpotato/core/providers/torrent/torrentbytes/main.py
index 63f8276..91939e7 100644
--- a/couchpotato/core/providers/torrent/torrentbytes/main.py
+++ b/couchpotato/core/providers/torrent/torrentbytes/main.py
@@ -11,12 +11,12 @@ log = CPLog(__name__)
class TorrentBytes(TorrentProvider):
urls = {
- 'test' : 'https://www.torrentbytes.net/',
- 'login' : 'https://www.torrentbytes.net/takelogin.php',
- 'login_check' : 'https://www.torrentbytes.net/inbox.php',
- 'detail' : 'https://www.torrentbytes.net/details.php?id=%s',
- 'search' : 'https://www.torrentbytes.net/browse.php?search=%s&cat=%d',
- 'download' : 'https://www.torrentbytes.net/download.php?id=%s&name=%s',
+ 'test': 'https://www.torrentbytes.net/',
+ 'login': 'https://www.torrentbytes.net/takelogin.php',
+ 'login_check': 'https://www.torrentbytes.net/inbox.php',
+ 'detail': 'https://www.torrentbytes.net/details.php?id=%s',
+ 'search': 'https://www.torrentbytes.net/browse.php?search=%s&cat=%d',
+ 'download': 'https://www.torrentbytes.net/download.php?id=%s&name=%s',
}
cat_ids = [
diff --git a/couchpotato/core/providers/torrent/torrentday/__init__.py b/couchpotato/core/providers/torrent/torrentday/__init__.py
index d98bb91..133ec91 100644
--- a/couchpotato/core/providers/torrent/torrentday/__init__.py
+++ b/couchpotato/core/providers/torrent/torrentday/__init__.py
@@ -1,5 +1,6 @@
from .main import TorrentDay
+
def start():
return TorrentDay()
diff --git a/couchpotato/core/providers/torrent/torrentday/main.py b/couchpotato/core/providers/torrent/torrentday/main.py
index ffd88f8..6d34323 100644
--- a/couchpotato/core/providers/torrent/torrentday/main.py
+++ b/couchpotato/core/providers/torrent/torrentday/main.py
@@ -23,7 +23,7 @@ class TorrentDay(TorrentProvider):
([5], ['bd50']),
]
- http_time_between_calls = 1 #seconds
+ http_time_between_calls = 1 #seconds
def _searchOnTitle(self, title, movie, quality, results):
diff --git a/couchpotato/core/providers/torrent/torrentleech/__init__.py b/couchpotato/core/providers/torrent/torrentleech/__init__.py
index c788477..e64d4ba 100644
--- a/couchpotato/core/providers/torrent/torrentleech/__init__.py
+++ b/couchpotato/core/providers/torrent/torrentleech/__init__.py
@@ -1,5 +1,6 @@
from .main import TorrentLeech
+
def start():
return TorrentLeech()
diff --git a/couchpotato/core/providers/torrent/torrentleech/main.py b/couchpotato/core/providers/torrent/torrentleech/main.py
index 017829b..ea6158d 100644
--- a/couchpotato/core/providers/torrent/torrentleech/main.py
+++ b/couchpotato/core/providers/torrent/torrentleech/main.py
@@ -12,12 +12,12 @@ log = CPLog(__name__)
class TorrentLeech(TorrentProvider):
urls = {
- 'test' : 'http://www.torrentleech.org/',
- 'login' : 'http://www.torrentleech.org/user/account/login/',
+ 'test': 'http://www.torrentleech.org/',
+ 'login': 'http://www.torrentleech.org/user/account/login/',
'login_check': 'http://torrentleech.org/user/messages',
- 'detail' : 'http://www.torrentleech.org/torrent/%s',
- 'search' : 'http://www.torrentleech.org/torrents/browse/index/query/%s/categories/%d',
- 'download' : 'http://www.torrentleech.org%s',
+ 'detail': 'http://www.torrentleech.org/torrent/%s',
+ 'search': 'http://www.torrentleech.org/torrents/browse/index/query/%s/categories/%d',
+ 'download': 'http://www.torrentleech.org%s',
}
cat_ids = [
diff --git a/couchpotato/core/providers/torrent/torrentpotato/__init__.py b/couchpotato/core/providers/torrent/torrentpotato/__init__.py
index 5054f98..03795ff 100644
--- a/couchpotato/core/providers/torrent/torrentpotato/__init__.py
+++ b/couchpotato/core/providers/torrent/torrentpotato/__init__.py
@@ -1,5 +1,6 @@
from .main import TorrentPotato
+
def start():
return TorrentPotato()
diff --git a/couchpotato/core/providers/torrent/torrentpotato/main.py b/couchpotato/core/providers/torrent/torrentpotato/main.py
index a76c0c8..eaaf8d2 100644
--- a/couchpotato/core/providers/torrent/torrentpotato/main.py
+++ b/couchpotato/core/providers/torrent/torrentpotato/main.py
@@ -15,7 +15,7 @@ class TorrentPotato(TorrentProvider):
urls = {}
limits_reached = {}
- http_time_between_calls = 1 # Seconds
+ http_time_between_calls = 1 # Seconds
def search(self, movie, quality):
hosts = self.getHosts()
diff --git a/couchpotato/core/providers/torrent/torrentshack/__init__.py b/couchpotato/core/providers/torrent/torrentshack/__init__.py
index 4171fc4..0e55211 100644
--- a/couchpotato/core/providers/torrent/torrentshack/__init__.py
+++ b/couchpotato/core/providers/torrent/torrentshack/__init__.py
@@ -1,5 +1,6 @@
from .main import TorrentShack
+
def start():
return TorrentShack()
diff --git a/couchpotato/core/providers/torrent/torrentshack/main.py b/couchpotato/core/providers/torrent/torrentshack/main.py
index 03a5f76..669c28f 100644
--- a/couchpotato/core/providers/torrent/torrentshack/main.py
+++ b/couchpotato/core/providers/torrent/torrentshack/main.py
@@ -11,12 +11,12 @@ log = CPLog(__name__)
class TorrentShack(TorrentProvider):
urls = {
- 'test' : 'https://torrentshack.net/',
- 'login' : 'https://torrentshack.net/login.php',
+ 'test': 'https://torrentshack.net/',
+ 'login': 'https://torrentshack.net/login.php',
'login_check': 'https://torrentshack.net/inbox.php',
- 'detail' : 'https://torrentshack.net/torrent/%s',
- 'search' : 'https://torrentshack.net/torrents.php?action=advanced&searchstr=%s&scene=%s&filter_cat[%d]=1',
- 'download' : 'https://torrentshack.net/%s',
+ 'detail': 'https://torrentshack.net/torrent/%s',
+ 'search': 'https://torrentshack.net/torrents.php?action=advanced&searchstr=%s&scene=%s&filter_cat[%d]=1',
+ 'download': 'https://torrentshack.net/%s',
}
cat_ids = [
diff --git a/couchpotato/core/providers/torrent/yify/__init__.py b/couchpotato/core/providers/torrent/yify/__init__.py
index 99c1162..8734af2 100644
--- a/couchpotato/core/providers/torrent/yify/__init__.py
+++ b/couchpotato/core/providers/torrent/yify/__init__.py
@@ -1,5 +1,6 @@
from main import Yify
+
def start():
return Yify()
diff --git a/couchpotato/core/providers/torrent/yify/main.py b/couchpotato/core/providers/torrent/yify/main.py
index 0b5e8b8..bb94016 100644
--- a/couchpotato/core/providers/torrent/yify/main.py
+++ b/couchpotato/core/providers/torrent/yify/main.py
@@ -9,13 +9,13 @@ log = CPLog(__name__)
class Yify(TorrentMagnetProvider):
urls = {
- 'test' : '%s/api',
- 'search' : '%s/api/list.json?keywords=%s&quality=%s',
+ 'test': '%s/api',
+ 'search': '%s/api/list.json?keywords=%s&quality=%s',
'detail': '%s/api/movie.json?id=%s'
}
- http_time_between_calls = 1 #seconds
-
+ http_time_between_calls = 1 #seconds
+
proxy_list = [
'https://yify-torrents.im',
'http://yify.unlocktorrent.com',
@@ -51,7 +51,7 @@ class Yify(TorrentMagnetProvider):
'id': result['MovieID'],
'name': title,
'url': result['TorrentMagnetUrl'],
- 'detail_url': self.urls['detail'] % (self.getDomain(),result['MovieID']),
+ 'detail_url': self.urls['detail'] % (self.getDomain(), result['MovieID']),
'size': self.parseSize(result['Size']),
'seeders': tryInt(result['TorrentSeeds']),
'leechers': tryInt(result['TorrentPeers'])
diff --git a/couchpotato/core/providers/trailer/hdtrailers/__init__.py b/couchpotato/core/providers/trailer/hdtrailers/__init__.py
index 016db7a..83b9300 100644
--- a/couchpotato/core/providers/trailer/hdtrailers/__init__.py
+++ b/couchpotato/core/providers/trailer/hdtrailers/__init__.py
@@ -1,5 +1,6 @@
from .main import HDTrailers
+
def start():
return HDTrailers()
diff --git a/couchpotato/core/providers/trailer/hdtrailers/main.py b/couchpotato/core/providers/trailer/hdtrailers/main.py
index 14b8554..cba7609 100644
--- a/couchpotato/core/providers/trailer/hdtrailers/main.py
+++ b/couchpotato/core/providers/trailer/hdtrailers/main.py
@@ -29,7 +29,7 @@ class HDTrailers(TrailerProvider):
log.debug('No page found for: %s', movie_name)
data = None
- result_data = {'480p':[], '720p':[], '1080p':[]}
+ result_data = {'480p': [], '720p': [], '1080p': []}
if not data:
return result_data
diff --git a/couchpotato/core/providers/userscript/allocine/__init__.py b/couchpotato/core/providers/userscript/allocine/__init__.py
index e451996..cb2ba99 100644
--- a/couchpotato/core/providers/userscript/allocine/__init__.py
+++ b/couchpotato/core/providers/userscript/allocine/__init__.py
@@ -1,5 +1,6 @@
from .main import AlloCine
+
def start():
return AlloCine()
diff --git a/couchpotato/core/providers/userscript/appletrailers/__init__.py b/couchpotato/core/providers/userscript/appletrailers/__init__.py
index e8078f4..075217a 100644
--- a/couchpotato/core/providers/userscript/appletrailers/__init__.py
+++ b/couchpotato/core/providers/userscript/appletrailers/__init__.py
@@ -1,5 +1,6 @@
from .main import AppleTrailers
+
def start():
return AppleTrailers()
diff --git a/couchpotato/core/providers/userscript/criticker/__init__.py b/couchpotato/core/providers/userscript/criticker/__init__.py
index 129d878..ae24aa1 100644
--- a/couchpotato/core/providers/userscript/criticker/__init__.py
+++ b/couchpotato/core/providers/userscript/criticker/__init__.py
@@ -1,5 +1,6 @@
from .main import Criticker
+
def start():
return Criticker()
diff --git a/couchpotato/core/providers/userscript/filmweb/__init__.py b/couchpotato/core/providers/userscript/filmweb/__init__.py
index 8ead54d..3098610 100644
--- a/couchpotato/core/providers/userscript/filmweb/__init__.py
+++ b/couchpotato/core/providers/userscript/filmweb/__init__.py
@@ -1,5 +1,6 @@
from .main import Filmweb
+
def start():
return Filmweb()
diff --git a/couchpotato/core/providers/userscript/flickchart/__init__.py b/couchpotato/core/providers/userscript/flickchart/__init__.py
index 89d45d9..18a88ff 100644
--- a/couchpotato/core/providers/userscript/flickchart/__init__.py
+++ b/couchpotato/core/providers/userscript/flickchart/__init__.py
@@ -1,5 +1,6 @@
from .main import Flickchart
+
def start():
return Flickchart()
diff --git a/couchpotato/core/providers/userscript/imdb/__init__.py b/couchpotato/core/providers/userscript/imdb/__init__.py
index f10505d..c25319b 100644
--- a/couchpotato/core/providers/userscript/imdb/__init__.py
+++ b/couchpotato/core/providers/userscript/imdb/__init__.py
@@ -1,5 +1,6 @@
from .main import IMDB
+
def start():
return IMDB()
diff --git a/couchpotato/core/providers/userscript/letterboxd/__init__.py b/couchpotato/core/providers/userscript/letterboxd/__init__.py
index c8c1797..2fd8900 100644
--- a/couchpotato/core/providers/userscript/letterboxd/__init__.py
+++ b/couchpotato/core/providers/userscript/letterboxd/__init__.py
@@ -1,5 +1,6 @@
from .main import Letterboxd
+
def start():
return Letterboxd()
diff --git a/couchpotato/core/providers/userscript/moviemeter/__init__.py b/couchpotato/core/providers/userscript/moviemeter/__init__.py
index 5e3813c..7a05a75 100644
--- a/couchpotato/core/providers/userscript/moviemeter/__init__.py
+++ b/couchpotato/core/providers/userscript/moviemeter/__init__.py
@@ -1,5 +1,6 @@
from .main import MovieMeter
+
def start():
return MovieMeter()
diff --git a/couchpotato/core/providers/userscript/moviesio/__init__.py b/couchpotato/core/providers/userscript/moviesio/__init__.py
index 473f847..e29e8d0 100644
--- a/couchpotato/core/providers/userscript/moviesio/__init__.py
+++ b/couchpotato/core/providers/userscript/moviesio/__init__.py
@@ -1,5 +1,6 @@
from .main import MoviesIO
+
def start():
return MoviesIO()
diff --git a/couchpotato/core/providers/userscript/rottentomatoes/__init__.py b/couchpotato/core/providers/userscript/rottentomatoes/__init__.py
index ee8266e..363f103 100644
--- a/couchpotato/core/providers/userscript/rottentomatoes/__init__.py
+++ b/couchpotato/core/providers/userscript/rottentomatoes/__init__.py
@@ -1,5 +1,6 @@
from .main import RottenTomatoes
+
def start():
return RottenTomatoes()
diff --git a/couchpotato/core/providers/userscript/sharethe/__init__.py b/couchpotato/core/providers/userscript/sharethe/__init__.py
index 7661f76..3cf393a 100644
--- a/couchpotato/core/providers/userscript/sharethe/__init__.py
+++ b/couchpotato/core/providers/userscript/sharethe/__init__.py
@@ -1,5 +1,6 @@
from .main import ShareThe
+
def start():
return ShareThe()
diff --git a/couchpotato/core/providers/userscript/tmdb/__init__.py b/couchpotato/core/providers/userscript/tmdb/__init__.py
index be33372..c77330c 100644
--- a/couchpotato/core/providers/userscript/tmdb/__init__.py
+++ b/couchpotato/core/providers/userscript/tmdb/__init__.py
@@ -1,5 +1,6 @@
from .main import TMDB
+
def start():
return TMDB()
diff --git a/couchpotato/core/providers/userscript/trakt/__init__.py b/couchpotato/core/providers/userscript/trakt/__init__.py
index ff67c1e..39c17c3 100644
--- a/couchpotato/core/providers/userscript/trakt/__init__.py
+++ b/couchpotato/core/providers/userscript/trakt/__init__.py
@@ -1,5 +1,6 @@
from .main import Trakt
+
def start():
return Trakt()
diff --git a/couchpotato/core/providers/userscript/whiwa/__init__.py b/couchpotato/core/providers/userscript/whiwa/__init__.py
index 6577ae3..c8fd3c9 100644
--- a/couchpotato/core/providers/userscript/whiwa/__init__.py
+++ b/couchpotato/core/providers/userscript/whiwa/__init__.py
@@ -1,5 +1,6 @@
from .main import WHiWA
+
def start():
return WHiWA()
diff --git a/couchpotato/core/providers/userscript/youteather/__init__.py b/couchpotato/core/providers/userscript/youteather/__init__.py
index a07bf56..f31e911 100644
--- a/couchpotato/core/providers/userscript/youteather/__init__.py
+++ b/couchpotato/core/providers/userscript/youteather/__init__.py
@@ -1,5 +1,6 @@
from .main import YouTheater
+
def start():
return YouTheater()
diff --git a/couchpotato/core/settings/model.py b/couchpotato/core/settings/model.py
index 8601c2b..ef6e8a5 100644
--- a/couchpotato/core/settings/model.py
+++ b/couchpotato/core/settings/model.py
@@ -18,6 +18,7 @@ options_defaults["shortnames"] = True
# http://elixir.ematia.de/trac/wiki/Recipes/MultipleDatabasesOneMetadata
__session__ = None
+
class SetEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, set):
@@ -40,6 +41,7 @@ class JsonType(TypeDecorator):
def process_result_value(self, value, dialect):
return json.loads(value if value else '{}')
+
class MutableDict(Mutable, dict):
@classmethod
@@ -78,7 +80,7 @@ class Movie(Entity):
such as trailers, nfo, thumbnails"""
last_edit = Field(Integer, default = lambda: int(time.time()), index = True)
- type = 'movie' # Compat tv branch
+ type = 'movie' # Compat tv branch
library = ManyToOne('Library', cascade = 'delete, delete-orphan', single_parent = True)
status = ManyToOne('Status')
@@ -87,7 +89,8 @@ class Movie(Entity):
releases = OneToMany('Release', cascade = 'all, delete-orphan')
files = ManyToMany('File', cascade = 'all, delete-orphan', single_parent = True)
-Media = Movie # Compat tv branch
+Media = Movie # Compat tv branch
+
class Library(Entity):
""""""
@@ -215,6 +218,7 @@ class Profile(Entity):
return orig_dict
+
class Category(Entity):
""""""
using_options(order_by = 'order')
diff --git a/couchpotato/environment.py b/couchpotato/environment.py
index b393ef9..5fb4329 100644
--- a/couchpotato/environment.py
+++ b/couchpotato/environment.py
@@ -6,6 +6,7 @@ from sqlalchemy.orm import scoped_session
from sqlalchemy.orm.session import sessionmaker
import os
+
class Env(object):
_appname = 'CouchPotato'
diff --git a/couchpotato/runner.py b/couchpotato/runner.py
index 36d4356..5c17520 100644
--- a/couchpotato/runner.py
+++ b/couchpotato/runner.py
@@ -18,6 +18,7 @@ import time
import traceback
import warnings
+
def getOptions(base_path, args):
# Options
@@ -52,6 +53,7 @@ def getOptions(base_path, args):
return options
+
# Tornado monkey patch logging..
def _log(status_code, request):
@@ -121,7 +123,6 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En
os.rmdir(backup)
total_backups -= 1
-
# Register environment settings
Env.set('app_dir', toUnicode(base_path))
Env.set('data_dir', toUnicode(data_dir))
@@ -234,10 +235,9 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En
'ssl_key': Env.setting('ssl_key', default = None),
}
-
# Load the app
application = Application([],
- log_function = lambda x : None,
+ log_function = lambda x: None,
debug = config['use_reloader'],
gzip = True,
cookie_secret = api_key,
@@ -250,9 +250,9 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En
(r'%snonblock/(.*)(/?)' % api_base, NonBlockHandler),
# API handlers
- (r'%s(.*)(/?)' % api_base, ApiHandler), # Main API handler
- (r'%sgetkey(/?)' % web_base, KeyHandler), # Get API key
- (r'%s' % api_base, RedirectHandler, {"url": web_base + 'docs/'}), # API docs
+ (r'%s(.*)(/?)' % api_base, ApiHandler), # Main API handler
+ (r'%sgetkey(/?)' % web_base, KeyHandler), # Get API key
+ (r'%s' % api_base, RedirectHandler, {"url": web_base + 'docs/'}), # API docs
# Login handlers
(r'%slogin(/?)' % web_base, LoginHandler),
@@ -267,37 +267,32 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En
static_path = '%sstatic/' % web_base
for dir_name in ['fonts', 'images', 'scripts', 'style']:
application.add_handlers(".*$", [
- ('%s%s/(.*)' % (static_path, dir_name), StaticFileHandler, {'path': toUnicode(os.path.join(base_path, 'couchpotato', 'static', dir_name))})
+ ('%s%s/(.*)' % (static_path, dir_name), StaticFileHandler, {'path': toUnicode(os.path.join(base_path, 'couchpotato', 'static', dir_name))})
])
Env.set('static_path', static_path)
-
# Load configs & plugins
loader = Env.get('loader')
loader.preload(root = toUnicode(base_path))
loader.run()
-
# Fill database with needed stuff
if not db_exists:
fireEvent('app.initialize', in_order = True)
-
# Go go go!
from tornado.ioloop import IOLoop
loop = IOLoop.current()
-
# Some logging and fire load event
try: log.info('Starting server on port %(port)s', config)
except: pass
fireEventAsync('app.load')
-
if config['ssl_cert'] and config['ssl_key']:
server = HTTPServer(application, no_keep_alive = True, ssl_options = {
- "certfile": config['ssl_cert'],
- "keyfile": config['ssl_key'],
+ 'certfile': config['ssl_cert'],
+ 'keyfile': config['ssl_key'],
})
else:
server = HTTPServer(application, no_keep_alive = True)
@@ -309,7 +304,7 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En
try:
server.listen(config['port'], config['host'])
loop.start()
- except Exception, e:
+ except Exception as e:
log.error('Failed starting: %s', traceback.format_exc())
try:
nr, msg = e