Browse Source

Code cleanup

pull/3423/head
Ruud 11 years ago
parent
commit
876c602710
  1. 2
      couchpotato/__init__.py
  2. 3
      couchpotato/core/_base/downloader/main.py
  3. 5
      couchpotato/core/_base/downloader/static/downloaders.js
  4. 2
      couchpotato/core/_base/updater/main.py
  5. 4
      couchpotato/core/downloaders/nzbvortex.py
  6. 2
      couchpotato/core/downloaders/sabnzbd.py
  7. 1
      couchpotato/core/downloaders/synology.py
  8. 2
      couchpotato/core/downloaders/utorrent.py
  9. 2
      couchpotato/core/media/__init__.py
  10. 1
      couchpotato/core/media/_base/media/main.py
  11. 3
      couchpotato/core/media/_base/providers/base.py
  12. 2
      couchpotato/core/media/_base/providers/nzb/newznab.py
  13. 1
      couchpotato/core/media/_base/providers/torrent/ilovetorrents.py
  14. 1
      couchpotato/core/media/_base/providers/torrent/torrentday.py
  15. 1
      couchpotato/core/media/_base/search/static/search.css
  16. 1
      couchpotato/core/media/movie/charts/main.py
  17. 1
      couchpotato/core/media/movie/charts/static/charts.css
  18. 17
      couchpotato/core/media/movie/providers/info/fanarttv.py
  19. 2
      couchpotato/core/media/movie/providers/info/themoviedb.py
  20. 1
      couchpotato/core/media/movie/providers/torrent/sceneaccess.py
  21. 3
      couchpotato/core/media/movie/providers/trailer/base.py
  22. 1
      couchpotato/core/media/movie/suggestion/main.py
  23. 2
      couchpotato/core/plugins/base.py
  24. 4
      couchpotato/core/plugins/file.py
  25. 4
      couchpotato/core/plugins/log/main.py
  26. 2
      couchpotato/core/plugins/log/static/log.css
  27. 2
      couchpotato/core/plugins/renamer.py
  28. 4
      couchpotato/core/plugins/wizard/static/wizard.js
  29. 1
      couchpotato/core/settings.py
  30. 4
      couchpotato/static/scripts/api.js
  31. 22
      couchpotato/static/scripts/library/question.js
  32. 4
      couchpotato/static/scripts/page/settings.js
  33. 2
      couchpotato/static/style/main.css

2
couchpotato/__init__.py

@ -45,7 +45,7 @@ class WebHandler(BaseHandler):
self.write({'success': False, 'error': 'Failed returning results'}) self.write({'success': False, 'error': 'Failed returning results'})
def addView(route, func, static = False): def addView(route, func):
views[route] = func views[route] = func

3
couchpotato/core/_base/downloader/main.py

@ -72,6 +72,9 @@ class DownloaderBase(Provider):
return return
return self.download(data = data, media = media, filedata = filedata) return self.download(data = data, media = media, filedata = filedata)
def download(self, *args, **kwargs):
return False
def _getAllDownloadStatus(self, download_ids): def _getAllDownloadStatus(self, download_ids):
if self.isDisabled(manual = True, data = {}): if self.isDisabled(manual = True, data = {}):
return return

5
couchpotato/core/_base/downloader/static/downloaders.js

@ -40,15 +40,16 @@ var DownloadersBase = new Class({
button.set('text', button_name); button.set('text', button_name);
var message;
if(json.success){ if(json.success){
var message = new Element('span.success', { message = new Element('span.success', {
'text': 'Connection successful' 'text': 'Connection successful'
}).inject(button, 'after') }).inject(button, 'after')
} }
else { else {
var msg_text = 'Connection failed. Check logs for details.'; var msg_text = 'Connection failed. Check logs for details.';
if(json.hasOwnProperty('msg')) msg_text = json.msg; if(json.hasOwnProperty('msg')) msg_text = json.msg;
var message = new Element('span.failed', { message = new Element('span.failed', {
'text': msg_text 'text': msg_text
}).inject(button, 'after') }).inject(button, 'after')
} }

2
couchpotato/core/_base/updater/main.py

@ -10,7 +10,7 @@ from threading import RLock
from couchpotato.api import addApiView from couchpotato.api import addApiView
from couchpotato.core.event import addEvent, fireEvent, fireEventAsync 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.logger import CPLog
from couchpotato.core.plugins.base import Plugin from couchpotato.core.plugins.base import Plugin
from couchpotato.environment import Env from couchpotato.environment import Env

4
couchpotato/core/downloaders/nzbvortex.py

@ -130,7 +130,7 @@ class NZBVortex(DownloaderBase):
url = cleanHost(self.conf('host'), ssl = self.conf('ssl')) + 'api/' + call url = cleanHost(self.conf('host'), ssl = self.conf('ssl')) + 'api/' + call
try: try:
data = self.urlopen('%s?%s' % (url, params), *args, verify_ssl = False, **kwargs) data = self.urlopen('%s?%s' % (url, params), *args, **kwargs)
if data: if data:
return json.loads(data) return json.loads(data)
@ -154,7 +154,7 @@ class NZBVortex(DownloaderBase):
url = cleanHost(self.conf('host')) + 'api/app/apilevel' url = cleanHost(self.conf('host')) + 'api/app/apilevel'
try: 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')) self.api_level = float(json.loads(data).get('apilevel'))
except URLError as e: except URLError as e:
if hasattr(e, 'code') and e.code == 403: if hasattr(e, 'code') and e.code == 403:

2
couchpotato/core/downloaders/sabnzbd.py

@ -194,7 +194,7 @@ class Sabnzbd(DownloaderBase):
'output': 'json' '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: if use_json:
d = json.loads(data) d = json.loads(data)
if d.get('error'): if d.get('error'):

1
couchpotato/core/downloaders/synology.py

@ -90,6 +90,7 @@ class SynologyRPC(object):
self.download_url = 'http://%s:%s/webapi/DownloadStation/task.cgi' % (host, port) self.download_url = 'http://%s:%s/webapi/DownloadStation/task.cgi' % (host, port)
self.auth_url = 'http://%s:%s/webapi/auth.cgi' % (host, port) self.auth_url = 'http://%s:%s/webapi/auth.cgi' % (host, port)
self.sid = None
self.username = username self.username = username
self.password = password self.password = password
self.destination = destination self.destination = destination

2
couchpotato/core/downloaders/utorrent.py

@ -168,7 +168,7 @@ class uTorrent(DownloaderBase):
status = 'busy' status = 'busy'
if (torrent[1] & self.status_flags['STARTED'] or torrent[1] & self.status_flags['QUEUED']) and torrent[4] == 1000: if (torrent[1] & self.status_flags['STARTED'] or torrent[1] & self.status_flags['QUEUED']) and torrent[4] == 1000:
status = 'seeding' status = 'seeding'
elif (torrent[1] & self.status_flags['ERROR']): elif torrent[1] & self.status_flags['ERROR']:
status = 'failed' status = 'failed'
elif torrent[4] == 1000: elif torrent[4] == 1000:
status = 'completed' status = 'completed'

2
couchpotato/core/media/__init__.py

@ -1,7 +1,7 @@
import os import os
import traceback import traceback
from couchpotato import get_db, CPLog from couchpotato import CPLog
from couchpotato.core.event import addEvent, fireEvent, fireEventAsync from couchpotato.core.event import addEvent, fireEvent, fireEventAsync
from couchpotato.core.helpers.encoding import toUnicode from couchpotato.core.helpers.encoding import toUnicode
from couchpotato.core.plugins.base import Plugin from couchpotato.core.plugins.base import Plugin

1
couchpotato/core/media/_base/media/main.py

@ -125,7 +125,6 @@ class MediaPlugin(MediaBase):
imdb_id = getImdb(str(media_id)) imdb_id = getImdb(str(media_id))
media = None
if imdb_id: if imdb_id:
media = db.get('media', 'imdb-%s' % imdb_id, with_doc = True)['doc'] media = db.get('media', 'imdb-%s' % imdb_id, with_doc = True)['doc']
else: else:

3
couchpotato/core/media/_base/providers/base.py

@ -129,6 +129,9 @@ class YarrProvider(Provider):
else: else:
return [] return []
def buildUrl(self, *args, **kwargs):
pass
def login(self): def login(self):
# Check if we are still logged in every hour # Check if we are still logged in every hour

2
couchpotato/core/media/_base/providers/nzb/newznab.py

@ -91,7 +91,7 @@ class Base(NZBProvider, RSS):
# Extract a password from the description # Extract a password from the description
password = re.search('(?:' + self.passwords_regex + ')(?: *)(?:\:|\=)(?: *)(.*?)\<br\>|\n|$', description, flags = re.I).group(1) password = re.search('(?:' + self.passwords_regex + ')(?: *)(?:\:|\=)(?: *)(.*?)\<br\>|\n|$', description, flags = re.I).group(1)
if password: if password:
name = name + ' {{%s}}' % password.strip() name += ' {{%s}}' % password.strip()
except: except:
log.debug('Error getting details of "%s": %s', (name, traceback.format_exc())) log.debug('Error getting details of "%s": %s', (name, traceback.format_exc()))

1
couchpotato/core/media/_base/providers/torrent/ilovetorrents.py

@ -51,6 +51,7 @@ class Base(TorrentProvider):
results_table = None results_table = None
data_split = splitString(data, '<table') data_split = splitString(data, '<table')
soup = None
for x in data_split: for x in data_split:
soup = BeautifulSoup(x) soup = BeautifulSoup(x)
results_table = soup.find('table', attrs = {'class': 'koptekst'}) results_table = soup.find('table', attrs = {'class': 'koptekst'})

1
couchpotato/core/media/_base/providers/torrent/torrentday.py

@ -1,4 +1,3 @@
from couchpotato.core.helpers.encoding import tryUrlencode
from couchpotato.core.helpers.variable import tryInt from couchpotato.core.helpers.variable import tryInt
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
from couchpotato.core.media._base.providers.torrent.base import TorrentProvider from couchpotato.core.media._base.providers.torrent.base import TorrentProvider

1
couchpotato/core/media/_base/search/static/search.css

@ -7,7 +7,6 @@
text-align: right; text-align: right;
height: 100%; height: 100%;
transition: all .4s cubic-bezier(0.9,0,0.1,1); transition: all .4s cubic-bezier(0.9,0,0.1,1);
position: absolute;
z-index: 20; z-index: 20;
border: 0 solid transparent; border: 0 solid transparent;
border-bottom-width: 4px; border-bottom-width: 4px;

1
couchpotato/core/media/movie/charts/main.py

@ -45,6 +45,7 @@ class Charts(Plugin):
if catched_charts: if catched_charts:
return catched_charts return catched_charts
charts = []
try: try:
self.update_in_progress = True self.update_in_progress = True
charts = fireEvent('automation.get_chart_list', merge = True) charts = fireEvent('automation.get_chart_list', merge = True)

1
couchpotato/core/media/movie/charts/static/charts.css

@ -148,7 +148,6 @@
padding: 0 3px 10px 0; padding: 0 3px 10px 0;
} }
.charts .chart .media_result .data:before { .charts .chart .media_result .data:before {
bottom: 0;
content: ''; content: '';
display: block; display: block;
height: 10px; height: 10px;

17
couchpotato/core/media/movie/providers/info/fanarttv.py

@ -51,19 +51,14 @@ class FanartTV(MovieProvider):
def _parseMovie(self, movie): def _parseMovie(self, movie):
images = { images = {
'landscape': [], 'landscape': self._getMultImages(movie.get('moviethumb', []), 1),
'logo': [], 'logo': [],
'disc_art': [], 'disc_art': self._getMultImages(self._trimDiscs(movie.get('moviedisc', [])), 1),
'clear_art': [], 'clear_art': self._getMultImages(movie.get('hdmovieart', []), 1),
'banner': [], 'banner': self._getMultImages(movie.get('moviebanner', []), 1),
'extra_fanart': [], '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: if len(images['clear_art']) == 0:
images['clear_art'] = self._getMultImages(movie.get('movieart', []), 1) images['clear_art'] = self._getMultImages(movie.get('movieart', []), 1)
@ -105,10 +100,10 @@ class FanartTV(MovieProvider):
return image_url return image_url
def _getMultImages(self, images, n): def _getMultImages(self, images, n):
''' """
Chooses the best n images and returns them as a list. Chooses the best n images and returns them as a list.
If n<0, all images will be returned. If n<0, all images will be returned.
''' """
image_urls = [] image_urls = []
pool = [] pool = []
for image in images: for image in images:

2
couchpotato/core/media/movie/providers/info/themoviedb.py

@ -1,6 +1,6 @@
import traceback 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.encoding import simplifyString, toUnicode, ss
from couchpotato.core.helpers.variable import tryInt from couchpotato.core.helpers.variable import tryInt
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog

1
couchpotato/core/media/movie/providers/torrent/sceneaccess.py

@ -1,5 +1,4 @@
from couchpotato.core.helpers.encoding import tryUrlencode from couchpotato.core.helpers.encoding import tryUrlencode
from couchpotato.core.event import fireEvent
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
from couchpotato.core.media._base.providers.torrent.sceneaccess import Base from couchpotato.core.media._base.providers.torrent.sceneaccess import Base
from couchpotato.core.media.movie.providers.base import MovieProvider from couchpotato.core.media.movie.providers.base import MovieProvider

3
couchpotato/core/media/movie/providers/trailer/base.py

@ -11,3 +11,6 @@ class TrailerProvider(Provider):
def __init__(self): def __init__(self):
addEvent('trailer.search', self.search) addEvent('trailer.search', self.search)
def search(self, *args, **kwargs):
pass

1
couchpotato/core/media/movie/suggestion/main.py

@ -84,7 +84,6 @@ class Suggestion(Plugin):
# Get new results and add them # Get new results and add them
if len(new_suggestions) - 1 < limit: if len(new_suggestions) - 1 < limit:
db = get_db()
active_movies = fireEvent('media.with_status', ['active', 'done'], single = True) active_movies = fireEvent('media.with_status', ['active', 'done'], single = True)
movies = [getIdentifier(x) for x in active_movies] movies = [getIdentifier(x) for x in active_movies]
movies.extend(seen) movies.extend(seen)

2
couchpotato/core/plugins/base.py

@ -166,7 +166,7 @@ class Plugin(object):
log.error('Couldn\'t remove empty directory %s: %s', (folder, traceback.format_exc())) log.error('Couldn\'t remove empty directory %s: %s', (folder, traceback.format_exc()))
# http request # 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 = "%/:=&?~#+!$,;'@()*[]") url = quote(ss(url), safe = "%/:=&?~#+!$,;'@()*[]")
if not headers: headers = {} if not headers: headers = {}

4
couchpotato/core/plugins/file.py

@ -49,8 +49,8 @@ class FileManager(Plugin):
files.extend(file_dict[x]) files.extend(file_dict[x])
for f in os.listdir(cache_dir): for f in os.listdir(cache_dir):
if os.path.splitext(f.name)[1] in ['.png', '.jpg', '.jpeg']: if os.path.splitext(f)[1] in ['.png', '.jpg', '.jpeg']:
file_path = os.path.join(cache_dir, f.name) file_path = os.path.join(cache_dir, f)
if toUnicode(file_path) not in files: if toUnicode(file_path) not in files:
os.remove(file_path) os.remove(file_path)
except: except:

4
couchpotato/core/plugins/log/main.py

@ -134,8 +134,8 @@ class Logging(Plugin):
logs_raw = toUnicode(log_content).split('[0m\n') logs_raw = toUnicode(log_content).split('[0m\n')
logs = [] logs = []
for log in logs_raw: for log_line in logs_raw:
split = splitString(log, '\x1b') split = splitString(log_line, '\x1b')
if split: if split:
try: try:
date, time, log_type = splitString(split[0], ' ') date, time, log_type = splitString(split[0], ' ')

2
couchpotato/core/plugins/log/static/log.css

@ -23,7 +23,7 @@
cursor: pointer; 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); background: rgba(255, 255, 255, 0.1);
} }

2
couchpotato/core/plugins/renamer.py

@ -456,7 +456,7 @@ class Renamer(Plugin):
mdia['last_edit'] = int(time.time()) mdia['last_edit'] = int(time.time())
db.update(mdia) db.update(mdia)
except Exception as e: except:
log.error('Failed marking movie finished: %s', (traceback.format_exc())) log.error('Failed marking movie finished: %s', (traceback.format_exc()))
# Go over current movie releases # Go over current movie releases

4
couchpotato/core/plugins/wizard/static/wizard.js

@ -90,7 +90,7 @@ Page.Wizard = new Class({
self.parent(action, params); self.parent(action, params);
self.addEvent('create', function(){ self.addEvent('create', function(){
self.order(); self.orderGroups();
}); });
self.initialized = true; self.initialized = true;
@ -106,7 +106,7 @@ Page.Wizard = new Class({
}).delay(1) }).delay(1)
}, },
order: function(){ orderGroups: function(){
var self = this; var self = this;
var form = self.el.getElement('.uniForm'); var form = self.el.getElement('.uniForm');

1
couchpotato/core/settings.py

@ -1,5 +1,4 @@
from __future__ import with_statement from __future__ import with_statement
import traceback
import ConfigParser import ConfigParser
from hashlib import md5 from hashlib import md5

4
couchpotato/static/scripts/api.js

@ -7,9 +7,9 @@ var ApiClass = new Class({
}, },
request: function(type, options){ 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({ return new Request[r_type](Object.merge({
'callbackKey': 'callback_func', 'callbackKey': 'callback_func',
'method': 'get', 'method': 'get',

22
couchpotato/static/scripts/library/question.js

@ -1,15 +1,15 @@
var Question = new Class( { var Question = new Class( {
initialize : function(question, hint, answers) { initialize : function(question, hint, answers) {
var self = this var self = this;
self.question = question self.question = question;
self.hint = hint self.hint = hint;
self.answers = answers self.answers = answers;
self.createQuestion(); self.createQuestion();
self.answers.each(function(answer) { self.answers.each(function(answer) {
self.createAnswer(answer) self.createAnswer(answer);
}) })
}, },
@ -29,14 +29,14 @@ var Question = new Class( {
}, },
createAnswer : function(options) { createAnswer : function(options) {
var self = this var self = this;
var answer = new Element('a', Object.merge(options, { var answer = new Element('a', Object.merge(options, {
'class' : 'answer button '+(options['class'] || '')+(options['cancel'] ? ' cancel' : '') 'class' : 'answer button '+(options['class'] || '')+(options['cancel'] ? ' cancel' : '')
})).inject(this.container) })).inject(this.container);
if (options.cancel) { if (options.cancel) {
answer.addEvent('click', self.close.bind(self)) answer.addEvent('click', self.close.bind(self));
} }
else if (options.request) { else if (options.request) {
answer.addEvent('click', function(e){ answer.addEvent('click', function(e){
@ -44,7 +44,7 @@ var Question = new Class( {
new Request(Object.merge(options, { new Request(Object.merge(options, {
'url': options.href, 'url': options.href,
'onComplete': function() { 'onComplete': function() {
(options.onComplete || function(){})() (options.onComplete || function(){})();
self.close(); self.close();
} }
})).send(); })).send();
@ -59,7 +59,7 @@ var Question = new Class( {
}, },
toElement : function() { toElement : function() {
return this.container return this.container;
} }
}) });

4
couchpotato/static/scripts/page/settings.js

@ -27,8 +27,8 @@ Page.Settings = new Class({
}, },
openTab: function(action){ openTab: function(action){
var self = this; var self = this,
var action = (action == 'index' ? 'about' : action) || self.action; action = (action == 'index' ? 'about' : action) || self.action;
if(self.current) if(self.current)
self.toggleTab(self.current, true); self.toggleTab(self.current, true);

2
couchpotato/static/style/main.css

@ -8,6 +8,7 @@ body, html {
padding: 0; padding: 0;
background: #4e5969; background: #4e5969;
-webkit-font-smoothing: subpixel-antialiased; -webkit-font-smoothing: subpixel-antialiased;
-moz-osx-font-smoothing: grayscale;
} }
body { overflow-y: scroll; } body { overflow-y: scroll; }
body.noscroll { overflow: hidden; } body.noscroll { overflow: hidden; }
@ -166,6 +167,7 @@ body > .spinner, .mask{
text-transform: none; text-transform: none;
line-height: 1; line-height: 1;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-size: 15px; font-size: 15px;
color: #FFF; color: #FFF;
} }

Loading…
Cancel
Save