Code cleanup
This commit is contained in:
@@ -45,7 +45,7 @@ class WebHandler(BaseHandler):
|
||||
self.write({'success': False, 'error': 'Failed returning results'})
|
||||
|
||||
|
||||
def addView(route, func, static = False):
|
||||
def addView(route, func):
|
||||
views[route] = func
|
||||
|
||||
|
||||
|
||||
@@ -72,6 +72,9 @@ class DownloaderBase(Provider):
|
||||
return
|
||||
return self.download(data = data, media = media, filedata = filedata)
|
||||
|
||||
def download(self, *args, **kwargs):
|
||||
return False
|
||||
|
||||
def _getAllDownloadStatus(self, download_ids):
|
||||
if self.isDisabled(manual = True, data = {}):
|
||||
return
|
||||
|
||||
@@ -40,15 +40,16 @@ var DownloadersBase = new Class({
|
||||
|
||||
button.set('text', button_name);
|
||||
|
||||
var message;
|
||||
if(json.success){
|
||||
var message = new Element('span.success', {
|
||||
message = new Element('span.success', {
|
||||
'text': 'Connection successful'
|
||||
}).inject(button, 'after')
|
||||
}
|
||||
else {
|
||||
var msg_text = 'Connection failed. Check logs for details.';
|
||||
if(json.hasOwnProperty('msg')) msg_text = json.msg;
|
||||
var message = new Element('span.failed', {
|
||||
message = new Element('span.failed', {
|
||||
'text': msg_text
|
||||
}).inject(button, 'after')
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ from threading import RLock
|
||||
|
||||
from couchpotato.api import addApiView
|
||||
from couchpotato.core.event import addEvent, fireEvent, fireEventAsync
|
||||
from couchpotato.core.helpers.encoding import ss, sp
|
||||
from couchpotato.core.helpers.encoding import sp
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.plugins.base import Plugin
|
||||
from couchpotato.environment import Env
|
||||
|
||||
@@ -130,7 +130,7 @@ class NZBVortex(DownloaderBase):
|
||||
url = cleanHost(self.conf('host'), ssl = self.conf('ssl')) + 'api/' + call
|
||||
|
||||
try:
|
||||
data = self.urlopen('%s?%s' % (url, params), *args, verify_ssl = False, **kwargs)
|
||||
data = self.urlopen('%s?%s' % (url, params), *args, **kwargs)
|
||||
|
||||
if data:
|
||||
return json.loads(data)
|
||||
@@ -154,7 +154,7 @@ class NZBVortex(DownloaderBase):
|
||||
url = cleanHost(self.conf('host')) + 'api/app/apilevel'
|
||||
|
||||
try:
|
||||
data = self.urlopen(url, show_error = False, verify_ssl = False)
|
||||
data = self.urlopen(url, show_error = False)
|
||||
self.api_level = float(json.loads(data).get('apilevel'))
|
||||
except URLError as e:
|
||||
if hasattr(e, 'code') and e.code == 403:
|
||||
|
||||
@@ -194,7 +194,7 @@ class Sabnzbd(DownloaderBase):
|
||||
'output': 'json'
|
||||
}))
|
||||
|
||||
data = self.urlopen(url, timeout = 60, show_error = False, verify_ssl = False, headers = {'User-Agent': Env.getIdentifier()}, **kwargs)
|
||||
data = self.urlopen(url, timeout = 60, show_error = False, headers = {'User-Agent': Env.getIdentifier()}, **kwargs)
|
||||
if use_json:
|
||||
d = json.loads(data)
|
||||
if d.get('error'):
|
||||
|
||||
@@ -90,6 +90,7 @@ class SynologyRPC(object):
|
||||
|
||||
self.download_url = 'http://%s:%s/webapi/DownloadStation/task.cgi' % (host, port)
|
||||
self.auth_url = 'http://%s:%s/webapi/auth.cgi' % (host, port)
|
||||
self.sid = None
|
||||
self.username = username
|
||||
self.password = password
|
||||
self.destination = destination
|
||||
|
||||
@@ -168,7 +168,7 @@ class uTorrent(DownloaderBase):
|
||||
status = 'busy'
|
||||
if (torrent[1] & self.status_flags['STARTED'] or torrent[1] & self.status_flags['QUEUED']) and torrent[4] == 1000:
|
||||
status = 'seeding'
|
||||
elif (torrent[1] & self.status_flags['ERROR']):
|
||||
elif torrent[1] & self.status_flags['ERROR']:
|
||||
status = 'failed'
|
||||
elif torrent[4] == 1000:
|
||||
status = 'completed'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
import traceback
|
||||
|
||||
from couchpotato import get_db, CPLog
|
||||
from couchpotato import CPLog
|
||||
from couchpotato.core.event import addEvent, fireEvent, fireEventAsync
|
||||
from couchpotato.core.helpers.encoding import toUnicode
|
||||
from couchpotato.core.plugins.base import Plugin
|
||||
|
||||
@@ -125,7 +125,6 @@ class MediaPlugin(MediaBase):
|
||||
|
||||
imdb_id = getImdb(str(media_id))
|
||||
|
||||
media = None
|
||||
if imdb_id:
|
||||
media = db.get('media', 'imdb-%s' % imdb_id, with_doc = True)['doc']
|
||||
else:
|
||||
|
||||
@@ -129,6 +129,9 @@ class YarrProvider(Provider):
|
||||
else:
|
||||
return []
|
||||
|
||||
def buildUrl(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
def login(self):
|
||||
|
||||
# Check if we are still logged in every hour
|
||||
|
||||
@@ -91,7 +91,7 @@ class Base(NZBProvider, RSS):
|
||||
# Extract a password from the description
|
||||
password = re.search('(?:' + self.passwords_regex + ')(?: *)(?:\:|\=)(?: *)(.*?)\<br\>|\n|$', description, flags = re.I).group(1)
|
||||
if password:
|
||||
name = name + ' {{%s}}' % password.strip()
|
||||
name += ' {{%s}}' % password.strip()
|
||||
except:
|
||||
log.debug('Error getting details of "%s": %s', (name, traceback.format_exc()))
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ class Base(TorrentProvider):
|
||||
results_table = None
|
||||
|
||||
data_split = splitString(data, '<table')
|
||||
soup = None
|
||||
for x in data_split:
|
||||
soup = BeautifulSoup(x)
|
||||
results_table = soup.find('table', attrs = {'class': 'koptekst'})
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from couchpotato.core.helpers.encoding import tryUrlencode
|
||||
from couchpotato.core.helpers.variable import tryInt
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.media._base.providers.torrent.base import TorrentProvider
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
text-align: right;
|
||||
height: 100%;
|
||||
transition: all .4s cubic-bezier(0.9,0,0.1,1);
|
||||
position: absolute;
|
||||
z-index: 20;
|
||||
border: 0 solid transparent;
|
||||
border-bottom-width: 4px;
|
||||
|
||||
@@ -45,6 +45,7 @@ class Charts(Plugin):
|
||||
if catched_charts:
|
||||
return catched_charts
|
||||
|
||||
charts = []
|
||||
try:
|
||||
self.update_in_progress = True
|
||||
charts = fireEvent('automation.get_chart_list', merge = True)
|
||||
|
||||
@@ -148,7 +148,6 @@
|
||||
padding: 0 3px 10px 0;
|
||||
}
|
||||
.charts .chart .media_result .data:before {
|
||||
bottom: 0;
|
||||
content: '';
|
||||
display: block;
|
||||
height: 10px;
|
||||
|
||||
@@ -51,19 +51,14 @@ class FanartTV(MovieProvider):
|
||||
|
||||
def _parseMovie(self, movie):
|
||||
images = {
|
||||
'landscape': [],
|
||||
'landscape': self._getMultImages(movie.get('moviethumb', []), 1),
|
||||
'logo': [],
|
||||
'disc_art': [],
|
||||
'clear_art': [],
|
||||
'banner': [],
|
||||
'disc_art': self._getMultImages(self._trimDiscs(movie.get('moviedisc', [])), 1),
|
||||
'clear_art': self._getMultImages(movie.get('hdmovieart', []), 1),
|
||||
'banner': self._getMultImages(movie.get('moviebanner', []), 1),
|
||||
'extra_fanart': [],
|
||||
}
|
||||
|
||||
images['landscape'] = self._getMultImages(movie.get('moviethumb', []), 1)
|
||||
images['banner'] = self._getMultImages(movie.get('moviebanner', []), 1)
|
||||
images['disc_art'] = self._getMultImages(self._trimDiscs(movie.get('moviedisc', [])), 1)
|
||||
|
||||
images['clear_art'] = self._getMultImages(movie.get('hdmovieart', []), 1)
|
||||
if len(images['clear_art']) == 0:
|
||||
images['clear_art'] = self._getMultImages(movie.get('movieart', []), 1)
|
||||
|
||||
@@ -105,10 +100,10 @@ class FanartTV(MovieProvider):
|
||||
return image_url
|
||||
|
||||
def _getMultImages(self, images, n):
|
||||
'''
|
||||
"""
|
||||
Chooses the best n images and returns them as a list.
|
||||
If n<0, all images will be returned.
|
||||
'''
|
||||
"""
|
||||
image_urls = []
|
||||
pool = []
|
||||
for image in images:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import traceback
|
||||
|
||||
from couchpotato.core.event import addEvent, fireEvent
|
||||
from couchpotato.core.event import addEvent
|
||||
from couchpotato.core.helpers.encoding import simplifyString, toUnicode, ss
|
||||
from couchpotato.core.helpers.variable import tryInt
|
||||
from couchpotato.core.logger import CPLog
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from couchpotato.core.helpers.encoding import tryUrlencode
|
||||
from couchpotato.core.event import fireEvent
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.media._base.providers.torrent.sceneaccess import Base
|
||||
from couchpotato.core.media.movie.providers.base import MovieProvider
|
||||
|
||||
@@ -11,3 +11,6 @@ class TrailerProvider(Provider):
|
||||
|
||||
def __init__(self):
|
||||
addEvent('trailer.search', self.search)
|
||||
|
||||
def search(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
@@ -84,7 +84,6 @@ class Suggestion(Plugin):
|
||||
|
||||
# Get new results and add them
|
||||
if len(new_suggestions) - 1 < limit:
|
||||
db = get_db()
|
||||
active_movies = fireEvent('media.with_status', ['active', 'done'], single = True)
|
||||
movies = [getIdentifier(x) for x in active_movies]
|
||||
movies.extend(seen)
|
||||
|
||||
@@ -166,7 +166,7 @@ class Plugin(object):
|
||||
log.error('Couldn\'t remove empty directory %s: %s', (folder, traceback.format_exc()))
|
||||
|
||||
# http request
|
||||
def urlopen(self, url, timeout = 30, data = None, headers = None, files = None, show_error = True, verify_ssl = True):
|
||||
def urlopen(self, url, timeout = 30, data = None, headers = None, files = None, show_error = True):
|
||||
url = quote(ss(url), safe = "%/:=&?~#+!$,;'@()*[]")
|
||||
|
||||
if not headers: headers = {}
|
||||
|
||||
@@ -49,8 +49,8 @@ class FileManager(Plugin):
|
||||
files.extend(file_dict[x])
|
||||
|
||||
for f in os.listdir(cache_dir):
|
||||
if os.path.splitext(f.name)[1] in ['.png', '.jpg', '.jpeg']:
|
||||
file_path = os.path.join(cache_dir, f.name)
|
||||
if os.path.splitext(f)[1] in ['.png', '.jpg', '.jpeg']:
|
||||
file_path = os.path.join(cache_dir, f)
|
||||
if toUnicode(file_path) not in files:
|
||||
os.remove(file_path)
|
||||
except:
|
||||
|
||||
@@ -134,8 +134,8 @@ class Logging(Plugin):
|
||||
logs_raw = toUnicode(log_content).split('[0m\n')
|
||||
|
||||
logs = []
|
||||
for log in logs_raw:
|
||||
split = splitString(log, '\x1b')
|
||||
for log_line in logs_raw:
|
||||
split = splitString(log_line, '\x1b')
|
||||
if split:
|
||||
try:
|
||||
date, time, log_type = splitString(split[0], ' ')
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.page.log .nav li:hover:not(.active, .filter) {
|
||||
.page.log .nav li:hover:not(.active):not(.filter) {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
|
||||
@@ -456,7 +456,7 @@ class Renamer(Plugin):
|
||||
mdia['last_edit'] = int(time.time())
|
||||
db.update(mdia)
|
||||
|
||||
except Exception as e:
|
||||
except:
|
||||
log.error('Failed marking movie finished: %s', (traceback.format_exc()))
|
||||
|
||||
# Go over current movie releases
|
||||
|
||||
@@ -90,7 +90,7 @@ Page.Wizard = new Class({
|
||||
self.parent(action, params);
|
||||
|
||||
self.addEvent('create', function(){
|
||||
self.order();
|
||||
self.orderGroups();
|
||||
});
|
||||
|
||||
self.initialized = true;
|
||||
@@ -106,7 +106,7 @@ Page.Wizard = new Class({
|
||||
}).delay(1)
|
||||
},
|
||||
|
||||
order: function(){
|
||||
orderGroups: function(){
|
||||
var self = this;
|
||||
|
||||
var form = self.el.getElement('.uniForm');
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from __future__ import with_statement
|
||||
import traceback
|
||||
import ConfigParser
|
||||
from hashlib import md5
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ var ApiClass = new Class({
|
||||
},
|
||||
|
||||
request: function(type, options){
|
||||
var self = this;
|
||||
var self = this,
|
||||
r_type = self.options.is_remote ? 'JSONP' : 'JSON';
|
||||
|
||||
var r_type = self.options.is_remote ? 'JSONP' : 'JSON';
|
||||
return new Request[r_type](Object.merge({
|
||||
'callbackKey': 'callback_func',
|
||||
'method': 'get',
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
var Question = new Class( {
|
||||
|
||||
initialize : function(question, hint, answers) {
|
||||
var self = this
|
||||
var self = this;
|
||||
|
||||
self.question = question
|
||||
self.hint = hint
|
||||
self.answers = answers
|
||||
self.question = question;
|
||||
self.hint = hint;
|
||||
self.answers = answers;
|
||||
|
||||
self.createQuestion();
|
||||
self.answers.each(function(answer) {
|
||||
self.createAnswer(answer)
|
||||
self.createAnswer(answer);
|
||||
})
|
||||
|
||||
},
|
||||
@@ -29,14 +29,14 @@ var Question = new Class( {
|
||||
},
|
||||
|
||||
createAnswer : function(options) {
|
||||
var self = this
|
||||
var self = this;
|
||||
|
||||
var answer = new Element('a', Object.merge(options, {
|
||||
'class' : 'answer button '+(options['class'] || '')+(options['cancel'] ? ' cancel' : '')
|
||||
})).inject(this.container)
|
||||
})).inject(this.container);
|
||||
|
||||
if (options.cancel) {
|
||||
answer.addEvent('click', self.close.bind(self))
|
||||
answer.addEvent('click', self.close.bind(self));
|
||||
}
|
||||
else if (options.request) {
|
||||
answer.addEvent('click', function(e){
|
||||
@@ -44,7 +44,7 @@ var Question = new Class( {
|
||||
new Request(Object.merge(options, {
|
||||
'url': options.href,
|
||||
'onComplete': function() {
|
||||
(options.onComplete || function(){})()
|
||||
(options.onComplete || function(){})();
|
||||
self.close();
|
||||
}
|
||||
})).send();
|
||||
@@ -59,7 +59,7 @@ var Question = new Class( {
|
||||
},
|
||||
|
||||
toElement : function() {
|
||||
return this.container
|
||||
return this.container;
|
||||
}
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
@@ -27,8 +27,8 @@ Page.Settings = new Class({
|
||||
},
|
||||
|
||||
openTab: function(action){
|
||||
var self = this;
|
||||
var action = (action == 'index' ? 'about' : action) || self.action;
|
||||
var self = this,
|
||||
action = (action == 'index' ? 'about' : action) || self.action;
|
||||
|
||||
if(self.current)
|
||||
self.toggleTab(self.current, true);
|
||||
|
||||
@@ -8,6 +8,7 @@ body, html {
|
||||
padding: 0;
|
||||
background: #4e5969;
|
||||
-webkit-font-smoothing: subpixel-antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
body { overflow-y: scroll; }
|
||||
body.noscroll { overflow: hidden; }
|
||||
@@ -166,6 +167,7 @@ body > .spinner, .mask{
|
||||
text-transform: none;
|
||||
line-height: 1;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
font-size: 15px;
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user