Merge branch 'master' of github.com:CouchPotato/CouchPotato

Conflicts:
	couchpotato/core/plugins/searcher/__init__.py
This commit is contained in:
Ruud
2011-08-19 16:15:51 +02:00
37 changed files with 1183 additions and 81 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ import os.path
import re
class Plugin():
class Plugin(object):
def conf(self, attr, default = None):
return Env.setting(attr, self.getName().lower(), default = default)
@@ -39,4 +39,4 @@ class Plugin():
return not self.isEnabled()
def isEnabled(self):
return self.conf('enabled')
return self.conf('enabled') or self.conf('enabled') == None
+9 -1
View File
@@ -149,6 +149,10 @@ class Renamer(Plugin):
if multiple:
cd += 1
# Notify on download
download_message = 'Download of %s (%s) successful.' % (group['library']['titles'][0]['title'], replacements['quality'])
fireEvent('notify', type = 'movie.downloaded', message = download_message, data = replacements)
# Before renaming, remove the lower quality files
db = get_session()
library = db.query(Library).filter_by(identifier = group['library']['identifier']).first()
@@ -172,6 +176,10 @@ class Renamer(Plugin):
for rename_me in rename_files:
filename = os.path.basename(rename_me)
rename_files[rename_me] = rename_me.replace(filename, '_EXISTS_%s' % filename)
# Notify on rename fail
download_message = 'Renaming of %s (%s) canceled, exists in %s already.' % (movie.library.titles[0].title, group['meta_data']['quality']['label'], release.quality.label)
fireEvent('notify', type = 'movie.renaming.canceled', message = download_message, data = group)
break
@@ -200,7 +208,7 @@ class Renamer(Plugin):
#print rename_me, rename_files[rename_me]
# Search for trailers
# Search for trailers etc
fireEvent('renamer.after', group)
def moveFile(self, old, dest, suppress = True):
+3 -1
View File
@@ -91,7 +91,6 @@ class Searcher(Plugin):
print successful
if successful:
log.info('Downloading of %s successful.' % nzb.get('name'))
# Mark release as snatched
db = get_session()
@@ -105,6 +104,9 @@ class Searcher(Plugin):
mvie.status_id = snatched_status.get('id')
db.commit()
log.info('Downloading of %s successful.' % nzb.get('name'))
fireEvent('notify', type = 'movie.snatched', message = 'Downloading of %s successful.' % nzb.get('name'), data = rls.to_dict())
return True
return False
@@ -0,0 +1,30 @@
from .main import Updater
def start():
return Updater()
config = [{
'name': 'updater',
'groups': [
{
'tab': 'general',
'name': 'updater',
'label': 'Updater',
'git_only': True,
'options': [
{
'name': 'enabled',
'default': True,
'type': 'enabler',
'description': 'Enable periodic update checking',
},
{
'name': 'automatic',
'default': False,
'type': 'enabler',
'description': 'Automaticly update when update is available',
},
],
},
],
}]
+79
View File
@@ -0,0 +1,79 @@
from couchpotato.core.event import addEvent, fireEvent
from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin
from couchpotato.environment import Env
from git.repository import LocalRepository
import time
log = CPLog(__name__)
class Updater(Plugin):
git = 'git://github.com/CouchPotato/CouchPotato.git'
running = False
version = None
updateFailed = False
updateAvailable = False
updateVersion = None
lastCheck = 0
def __init__(self):
self.repo = LocalRepository(Env.get('app_dir'))
fireEvent('schedule.interval', 'updater.check', self.check, hours = 6)
addEvent('app.load', self.check)
def getVersion(self):
if not self.version:
try:
output = self.repo.getHead() # Yes, please
log.debug('Git version output: %s' % output.hash)
self.version = output.hash
except Exception, e:
log.error('Failed using GIT updater, running from source, you need to have GIT installed. %s' % e)
return 'No GIT'
return self.version
def check(self):
if self.updateAvailable or self.isDisabled():
return
current_branch = self.repo.getCurrentBranch().name
for branch in self.repo.getRemoteByName('origin').getBranches():
if current_branch == branch.name:
local = self.repo.getHead()
remote = branch.getHead()
if local.getDate() < remote.getDate():
if self.conf('automatic') and not self.updateFailed:
self.doUpdate()
else:
self.updateAvailable = True
self.updateVersion = remote.hash
self.lastCheck = time.time()
def doUpdate(self):
try:
log.info('Updating to latest version');
self.repo.pull()
return True
except Exception, e:
log.error('Failed updating via GIT: %s' % e)
self.updateFailed = True
return False
def isEnabled(self):
return Plugin.isEnabled(self) and Env.get('uses_git')