XBMC Metadata
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
from couchpotato.core.event import addEvent, fireEvent
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.plugins.base import Plugin
|
||||
import os.path
|
||||
import shutil
|
||||
import traceback
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
@@ -10,7 +13,7 @@ class MetaDataBase(Plugin):
|
||||
enabled_option = 'meta_enabled'
|
||||
|
||||
def __init__(self):
|
||||
addEvent('metadata.create', self.create)
|
||||
addEvent('renamer.after', self.create)
|
||||
|
||||
def create(self, release):
|
||||
if self.isDisabled(): return
|
||||
@@ -29,11 +32,14 @@ class MetaDataBase(Plugin):
|
||||
# Get file content
|
||||
content = getattr(self, 'get' + type.capitalize())(release)
|
||||
if content:
|
||||
log.debug('Creating %s file: %s' % (type, name))
|
||||
self.createFile(name, content)
|
||||
if os.path.isfile(content):
|
||||
shutil.copy2(content, name)
|
||||
else:
|
||||
log.debug('Creating %s file: %s' % (type, name))
|
||||
self.createFile(name, content)
|
||||
|
||||
except Exception, e:
|
||||
log.error('Unable to create %s file: %s' % (type, e))
|
||||
log.error('Unable to create %s file: %s' % (type, traceback.format_exc()))
|
||||
|
||||
def getRootName(self, data):
|
||||
return
|
||||
@@ -50,8 +56,15 @@ class MetaDataBase(Plugin):
|
||||
def getNfo(self, data):
|
||||
return
|
||||
|
||||
def getThumbnail(self, data):
|
||||
return
|
||||
def getThumbnail(self, data, file_type = 'poster_original'):
|
||||
file_types = fireEvent('file.types', single = True)
|
||||
for type in file_types:
|
||||
if type.get('identifier') == file_type:
|
||||
break
|
||||
|
||||
for file in data['library'].get('files'):
|
||||
if file.get('type_id') is type.get('id'):
|
||||
return file.get('path')
|
||||
|
||||
def getFanart(self, data):
|
||||
return
|
||||
return self.getThumbnail(data, file_type = 'backdrop_original')
|
||||
|
||||
Reference in New Issue
Block a user