You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.2 KiB

import traceback
11 years ago
from couchpotato import get_db, CPLog
from couchpotato.core.event import addEvent, fireEvent, fireEventAsync
from couchpotato.core.plugins.base import Plugin
11 years ago
log = CPLog(__name__)
class MediaBase(Plugin):
_type = None
def initType(self):
addEvent('media.types', self.getType)
def getType(self):
return self._type
11 years ago
def createOnComplete(self, media_id):
def onComplete():
try:
11 years ago
db = get_db()
media = db.get('id', media_id)
event_name = '%s.searcher.single' % media.get('type')
11 years ago
fireEventAsync(event_name, media, on_complete = self.createNotifyFront(media_id))
except:
log.error('Failed creating onComplete: %s', traceback.format_exc())
return onComplete
def createNotifyFront(self, media_id):
def notifyFront():
try:
11 years ago
db = get_db()
media = db.get('id', media_id)
event_name = '%s.update' % media.get('type')
11 years ago
fireEvent('notify.frontend', type = event_name, data = media)
except:
log.error('Failed creating onComplete: %s', traceback.format_exc())
return notifyFront