Merge branch 'refs/heads/develop'

This commit is contained in:
Ruud committed 2014-06-06 11:24:24 +02:00
commit b6ee8ef4d4
5 files changed
+38 -38

No files matched your search

+2 -1
View File
@@ -36,7 +36,8 @@ Linux (Ubuntu / Debian):
* Run `git clone https://github.com/RuudBurger/CouchPotatoServer.git` * Run `git clone https://github.com/RuudBurger/CouchPotatoServer.git`
* Then do `python CouchPotatoServer/CouchPotato.py` to start * Then do `python CouchPotatoServer/CouchPotato.py` to start
* To run on boot copy the init script `sudo cp CouchPotatoServer/init/ubuntu /etc/init.d/couchpotato` * To run on boot copy the init script `sudo cp CouchPotatoServer/init/ubuntu /etc/init.d/couchpotato`
* Change the paths inside the init script `sudo nano /etc/init.d/couchpotato` * Copy the default paths file `sudo cp CouchPotatoServer/init/ubuntu.default /etc/default/couchpotato`
* Change the paths inside the default file `sudo nano /etc/default/couchpotato`
* Make it executable `sudo chmod +x /etc/init.d/couchpotato` * Make it executable `sudo chmod +x /etc/init.d/couchpotato`
* Add it to defaults `sudo update-rc.d couchpotato defaults` * Add it to defaults `sudo update-rc.d couchpotato defaults`
* Open your browser and go to `http://localhost:5050/` * Open your browser and go to `http://localhost:5050/`
+14 -27
View File
@@ -40,7 +40,6 @@ class Plugin(object):
http_time_between_calls = 0 http_time_between_calls = 0
http_failed_request = {} http_failed_request = {}
http_failed_disabled = {} http_failed_disabled = {}
http_opener = requests.Session()
def __new__(cls, *args, **kwargs): def __new__(cls, *args, **kwargs):
new_plugin = super(Plugin, cls).__new__(cls) new_plugin = super(Plugin, cls).__new__(cls)
@@ -143,34 +142,22 @@ class Plugin(object):
def deleteEmptyFolder(self, folder, show_error = True, only_clean = None): def deleteEmptyFolder(self, folder, show_error = True, only_clean = None):
folder = sp(folder) folder = sp(folder)
allowed_dirs = [] for item in os.listdir(folder):
if only_clean: full_folder = os.path.join(folder, item)
for item in os.listdir(folder):
full_path = os.path.join(folder, item)
if item in only_clean and os.path.isdir(full_path):
allowed_dirs.append(full_path)
for root, dirs, files in os.walk(folder): if not only_clean or (item in only_clean and os.path.isdir(full_folder)):
for dir_name in dirs: for root, dirs, files in os.walk(full_folder):
full_path = os.path.join(root, dir_name)
if only_clean: for dir_name in dirs:
allow = False full_path = os.path.join(root, dir_name)
for allowed_dir in allowed_dirs:
if allowed_dir in full_path:
allow = True
break
if not allow: if len(os.listdir(full_path)) == 0:
continue try:
os.rmdir(full_path)
if len(os.listdir(full_path)) == 0: except:
try: if show_error:
os.rmdir(full_path) log.error('Couldn\'t remove empty directory %s: %s', (full_path, traceback.format_exc()))
except:
if show_error:
log.error('Couldn\'t remove empty directory %s: %s', (full_path, traceback.format_exc()))
try: try:
os.rmdir(folder) os.rmdir(folder)
@@ -196,7 +183,7 @@ class Plugin(object):
headers['Connection'] = headers.get('Connection', 'keep-alive') headers['Connection'] = headers.get('Connection', 'keep-alive')
headers['Cache-Control'] = headers.get('Cache-Control', 'max-age=0') headers['Cache-Control'] = headers.get('Cache-Control', 'max-age=0')
r = self.http_opener r = Env.get('http_opener')
# Don't try for failed requests # Don't try for failed requests
if self.http_failed_disabled.get(host, 0) > 0: if self.http_failed_disabled.get(host, 0) > 0:
@@ -218,7 +205,7 @@ class Plugin(object):
'data': data if len(data) > 0 else None, 'data': data if len(data) > 0 else None,
'timeout': timeout, 'timeout': timeout,
'files': files, 'files': files,
'verify': verify_ssl, 'verify': False, #verify_ssl, Disable for now as to many wrongly implemented certificates..
} }
method = 'post' if len(data) > 0 or files else 'get' method = 'post' if len(data) > 0 or files else 'get'
+19 -8
View File
@@ -207,15 +207,22 @@ class QualityPlugin(Plugin):
self.calcScore(score, quality, contains_score, threedscore) self.calcScore(score, quality, contains_score, threedscore)
# Evaluate score based on size size_scores = []
for quality in qualities: for quality in qualities:
size_score = self.guessSizeScore(quality, size = size)
self.calcScore(score, quality, size_score, penalty = False)
# Try again with loose testing # Evaluate score based on size
for quality in qualities: size_score = self.guessSizeScore(quality, size = size)
loose_score = self.guessLooseScore(quality, extra = extra) loose_score = self.guessLooseScore(quality, extra = extra)
self.calcScore(score, quality, loose_score, penalty = False)
if size_score > 0:
size_scores.append(quality)
self.calcScore(score, quality, size_score + loose_score, penalty = False)
# Add additional size score if only 1 size validated
if len(size_scores) == 1:
self.calcScore(score, size_scores[0], 10, penalty = False)
del size_scores
# Return nothing if all scores are <= 0 # Return nothing if all scores are <= 0
has_non_zero = 0 has_non_zero = 0
@@ -325,6 +332,8 @@ class QualityPlugin(Plugin):
if tryInt(quality['size_min']) <= tryInt(size) <= tryInt(quality['size_max']): if tryInt(quality['size_min']) <= tryInt(size) <= tryInt(quality['size_max']):
log.debug('Found %s via release size: %s MB < %s MB < %s MB', (quality['identifier'], quality['size_min'], size, quality['size_max'])) log.debug('Found %s via release size: %s MB < %s MB < %s MB', (quality['identifier'], quality['size_min'], size, quality['size_max']))
score += 5 score += 5
else:
score -= 5
return score return score
@@ -351,7 +360,8 @@ class QualityPlugin(Plugin):
# Give panelty for all lower qualities # Give panelty for all lower qualities
for q in self.qualities[self.order.index(quality.get('identifier'))+1:]: for q in self.qualities[self.order.index(quality.get('identifier'))+1:]:
score[q.get('identifier')]['score'] -= 1 if score.get(q.get('identifier')):
score[q.get('identifier')]['score'] -= 1
def isFinish(self, quality, profile): def isFinish(self, quality, profile):
if not isinstance(profile, dict) or not profile.get('qualities'): if not isinstance(profile, dict) or not profile.get('qualities'):
@@ -412,6 +422,7 @@ class QualityPlugin(Plugin):
'Movie Name (2013) 2D + 3D': {'size': 49000, 'quality': 'bd50', 'is_3d': True}, 'Movie Name (2013) 2D + 3D': {'size': 49000, 'quality': 'bd50', 'is_3d': True},
'Movie Monuments 2013 BrRip 1080p': {'size': 1800, 'quality': 'brrip'}, 'Movie Monuments 2013 BrRip 1080p': {'size': 1800, 'quality': 'brrip'},
'Movie Monuments 2013 BrRip 720p': {'size': 1300, 'quality': 'brrip'}, 'Movie Monuments 2013 BrRip 720p': {'size': 1300, 'quality': 'brrip'},
'The.Movie.2014.3D.1080p.BluRay.AVC.DTS-HD.MA.5.1-GroupName': {'size': 30000, 'quality': 'bd50', 'is_3d': True},
} }
correct = 0 correct = 0
@@ -419,7 +430,7 @@ class QualityPlugin(Plugin):
test_quality = self.guess(files = [name], extra = tests[name].get('extra', None), size = tests[name].get('size', None)) or {} test_quality = self.guess(files = [name], extra = tests[name].get('extra', None), size = tests[name].get('size', None)) or {}
success = test_quality.get('identifier') == tests[name]['quality'] and test_quality.get('is_3d') == tests[name].get('is_3d', False) success = test_quality.get('identifier') == tests[name]['quality'] and test_quality.get('is_3d') == tests[name].get('is_3d', False)
if not success: if not success:
log.error('%s failed check, thinks it\'s %s', (name, self.guess([name]).get('identifier'))) log.error('%s failed check, thinks it\'s %s', (name, test_quality.get('identifier')))
correct += success correct += success
+1 -2
View File
@@ -24,8 +24,7 @@ class Env(object):
_quiet = False _quiet = False
_daemonized = False _daemonized = False
_desktop = None _desktop = None
_engine = None _http_opener = None
_session = None
''' Data paths and directories ''' ''' Data paths and directories '''
_app_dir = "" _app_dir = ""
+2
View File
@@ -18,6 +18,7 @@ from couchpotato.api import NonBlockHandler, ApiHandler
from couchpotato.core.event import fireEventAsync, fireEvent from couchpotato.core.event import fireEventAsync, fireEvent
from couchpotato.core.helpers.encoding import sp from couchpotato.core.helpers.encoding import sp
from couchpotato.core.helpers.variable import getDataDir, tryInt from couchpotato.core.helpers.variable import getDataDir, tryInt
import requests
from tornado.httpserver import HTTPServer from tornado.httpserver import HTTPServer
from tornado.web import Application, StaticFileHandler, RedirectHandler from tornado.web import Application, StaticFileHandler, RedirectHandler
@@ -141,6 +142,7 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En
Env.set('data_dir', sp(data_dir)) Env.set('data_dir', sp(data_dir))
Env.set('log_path', sp(os.path.join(log_dir, 'CouchPotato.log'))) Env.set('log_path', sp(os.path.join(log_dir, 'CouchPotato.log')))
Env.set('db', db) Env.set('db', db)
Env.set('http_opener', requests.Session())
Env.set('cache_dir', cache_dir) Env.set('cache_dir', cache_dir)
Env.set('cache', FileSystemCache(python_cache)) Env.set('cache', FileSystemCache(python_cache))
Env.set('console_log', options.console_log) Env.set('console_log', options.console_log)