Browse Source

Log nr

pull/51/merge
Ruud 14 years ago
parent
commit
c6f322a2c2
  1. 18
      couchpotato/core/plugins/log/main.py
  2. 4
      couchpotato/core/providers/trailer/hdtrailers/main.py
  3. 32
      couchpotato/static/scripts/page/log.js

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

@ -2,6 +2,7 @@ from couchpotato.api import addApiView
from couchpotato.core.helpers.request import jsonified, getParam from couchpotato.core.helpers.request import jsonified, getParam
from couchpotato.core.plugins.base import Plugin from couchpotato.core.plugins.base import Plugin
from couchpotato.environment import Env from couchpotato.environment import Env
import os
class Logging(Plugin): class Logging(Plugin):
@ -12,10 +13,22 @@ class Logging(Plugin):
def get(self): def get(self):
nr = int(getParam('nr', 0)) nr = int(getParam('nr', 0))
path = '%s%s' % (Env.get('log_path'), '.%s' % nr if nr > 0 else '')
total = 1
for x in range(0, 50):
path = '%s%s' % (Env.get('log_path'), '.%s' % x if x > 0 else '')
# Set current path
if x is nr:
current_path = path
# Check see if the log exists
if not os.path.isfile(path):
total = x
break
# Reverse # Reverse
f = open(path, 'r') f = open(current_path, 'r')
lines = [] lines = []
for line in f.readlines(): for line in f.readlines():
lines.insert(0, line) lines.insert(0, line)
@ -27,4 +40,5 @@ class Logging(Plugin):
return jsonified({ return jsonified({
'success': True, 'success': True,
'log': log, 'log': log,
'total': total,
}) })

4
couchpotato/core/providers/trailer/hdtrailers/main.py

@ -45,7 +45,6 @@ class HDTrailers(TrailerProvider):
results = {'480p':[], '720p':[], '1080p':[]} results = {'480p':[], '720p':[], '1080p':[]}
url = "%s?%s" % (self.url['backup'], urlencode({'s':movie})) url = "%s?%s" % (self.url['backup'], urlencode({'s':movie}))
data = self.urlopen(url) data = self.urlopen(url)
try: try:
@ -63,7 +62,6 @@ class HDTrailers(TrailerProvider):
except: except:
pass pass
except AttributeError: except AttributeError:
log.debug('No trailers found in via alternative.') log.debug('No trailers found in via alternative.')
@ -85,10 +83,8 @@ class HDTrailers(TrailerProvider):
if 'trailer' in trtext and not 'clip' in trtext and provider in trtext: if 'trailer' in trtext and not 'clip' in trtext and provider in trtext:
nr = 0 nr = 0
resolutions = tr.findAll('td', attrs = {'class':'bottomTableResolution'}) resolutions = tr.findAll('td', attrs = {'class':'bottomTableResolution'})
#sizes = tr.findNext('tr').findAll('td', attrs = {'class':'bottomTableFileSize'})
for res in resolutions: for res in resolutions:
results[str(res.a.contents[0])].insert(0, res.a['href']) results[str(res.a.contents[0])].insert(0, res.a['href'])
#int(sizes[nr].contents[0].replace('MB', ''))
nr += 1 nr += 1
return results return results

32
couchpotato/static/scripts/page/log.js

@ -4,24 +4,42 @@ Page.Log = new Class({
name: 'log', name: 'log',
title: 'Show recent logs.', title: 'Show recent logs.',
indexAction: function(){ indexAction: function(){
var self = this; var self = this;
self.getLogs(0);
},
getLogs: function(nr){
var self = this;
if(self.log) self.log.destroy(); if(self.log) self.log.destroy();
self.log = new Element('div.log', { self.log = new Element('div.log', {
'text': 'loading...' 'text': 'loading...'
}).inject(self.el) }).inject(self.el);
Api.request('logging.get', { Api.request('logging.get', {
'data': { 'data': {
'nr': 0 'nr': nr
}, },
'onComplete': function(json){ 'onComplete': function(json){
self.log.set('html', '<pre>'+json.log+'</pre>') self.log.set('html', '<pre>'+json.log+'</pre>')
var nav = new Element('ul.nav').inject(self.log, 'top');
for (var i = 0; i < json.total; i++) {
p(i, json.total);
new Element('li', {
'text': i+1,
'events': {
'click': function(){ self.getLogs(i); }
}
}).inject(nav)
};
} }
}) });
} }
}) })
Loading…
Cancel
Save