New model implemented to work with both Movies and TV Shows as well any future types. Currenly episodes are mapped directly to shows; no seasons yet. Will get around to that soon. This version allows you to add any tv show and it will appear in wanted list, but no searches are written yet :)

This commit is contained in:
Jason Mehring
2013-08-18 03:28:41 -04:00
parent 31cd993506
commit 029cf9ecac
21 changed files with 193 additions and 4039 deletions
+27 -3
View File
@@ -20,22 +20,36 @@ class LibraryPlugin(Plugin):
addEvent('library.update', self.update)
addEvent('library.update_release_date', self.updateReleaseDate)
def add(self, attrs = {}, update_after = True, type='movie'):
def add(self, attrs = {}, update_after = True):
# movies don't yet contain these, so lets make sure to set defaults
type = attrs.get('type', 'movie')
primary_provider = attrs.get('primary_provider', 'imdb')
db = get_session()
parent_identifier = attrs.get('parent_identifier', None)
# XXX: add type (somehow? it will be show when episode id the type) so we dont get conflicts
parent = None
if parent_identifier:
#parent = db.query(Library).filter_by(identifier = attrs.get('parent_identifier')).first()
parent = db.query(Library).filter_by(primary_provider = primary_provider, identifier = attrs.get('parent_identifier')).first()
l = db.query(Library).filter_by(identifier = attrs.get('identifier')).first()
l = db.query(Library).filter_by(type = type, identifier = attrs.get('identifier')).first()
if not l:
status = fireEvent('status.get', 'needs_update', single = True)
l = Library(
type = type,
primary_provider = primary_provider,
year = attrs.get('year'),
identifier = attrs.get('identifier'),
plot = toUnicode(attrs.get('plot')),
tagline = toUnicode(attrs.get('tagline')),
status_id = status.get('id'),
info = {},
parent = parent,
)
# children = [],
title = LibraryTitle(
title = toUnicode(attrs.get('title')),
@@ -71,10 +85,20 @@ class LibraryPlugin(Plugin):
do_update = True
# XXX: Fix to be pretty
parent_identifier = None
if library.parent:
parent_identifier = library.parent.identifier
if library.status_id == done_status.get('id') and not force:
do_update = False
# XXX: do this a better way. we need to pass parent_identifier to things like episode.info
# maybe just make all .info (movie, show, season and esisode requre parent var and not use it)
elif parent_identifier:
info = fireEvent('%s.info' % library.type, merge = True, identifier = identifier, \
parent_identifier = parent_identifier)
else:
info = fireEvent('movie.info', merge = True, identifier = identifier)
info = fireEvent('%s.info' % library.type, merge = True, identifier = identifier)
# Don't need those here
try: del info['in_wanted']