def add(self, attrs={}, update_after=True): db = get_session() l = db.query(Library).filter_by( identifier=attrs.get('identifier')).first() if not l: status = fireEvent('status.get', 'needs_update', single=True) l = Library(year=attrs.get('year'), identifier=attrs.get('identifier'), plot=attrs.get('plot'), tagline=attrs.get('tagline'), status_id=status.get('id')) title = LibraryTitle(title=attrs.get('title')) l.titles.append(title) db.add(l) db.commit() # Update library info if update_after: fireEventAsync('library.update', identifier=l.identifier, default_title=attrs.get('title', '')) return l.to_dict(self.default_dict)
def add(self, attrs={}, update_after=True): db = get_session() l = db.query(Library).filter_by(identifier=attrs.get("identifier")).first() if not l: status = fireEvent("status.get", "needs_update", single=True) l = Library( year=attrs.get("year"), identifier=attrs.get("identifier"), plot=toUnicode(attrs.get("plot")), tagline=toUnicode(attrs.get("tagline")), status_id=status.get("id"), ) title = LibraryTitle( title=toUnicode(attrs.get("title")), simple_title=self.simplifyTitle(attrs.get("title")) ) l.titles.append(title) db.add(l) db.commit() # Update library info if update_after is not False: handle = fireEventAsync if update_after is "async" else fireEvent handle("library.update", identifier=l.identifier, default_title=attrs.get("title", "")) return l.to_dict(self.default_dict)
def add(self, attrs={}, update_after=True): db = get_session() l = db.query(Library).filter_by( identifier=attrs.get('identifier')).first() if not l: status = fireEvent('status.get', 'needs_update', single=True) l = Library(year=attrs.get('year'), identifier=attrs.get('identifier'), plot=toUnicode(attrs.get('plot')), tagline=toUnicode(attrs.get('tagline')), status_id=status.get('id')) title = LibraryTitle(title=toUnicode(attrs.get('title')), simple_title=self.simplifyTitle( attrs.get('title'))) l.titles.append(title) db.add(l) db.commit() # Update library info if update_after is not False: handle = fireEventAsync if update_after is 'async' else fireEvent handle('library.update', identifier=l.identifier, default_title=toUnicode(attrs.get('title', ''))) library_dict = l.to_dict(self.default_dict) return library_dict
def add(self, attrs = {}, update_after = True): db = get_session() l = db.query(Library).filter_by(identifier = attrs.get('identifier')).first() if not l: status = fireEvent('status.get', 'needs_update', single = True) l = Library( year = attrs.get('year'), identifier = attrs.get('identifier'), plot = attrs.get('plot'), tagline = attrs.get('tagline'), status_id = status.get('id') ) title = LibraryTitle( title = attrs.get('title') ) l.titles.append(title) db.add(l) db.commit() # Update library info if update_after: fireEventAsync('library.update', identifier = l.identifier, default_title = attrs.get('title', '')) return l.to_dict(self.default_dict)
def add(self, attrs = {}, update_after = True): db = get_session() l = db.query(Library).filter_by(identifier = attrs.get('identifier')).first() if not l: status = fireEvent('status.get', 'needs_update', single = True) l = Library( year = attrs.get('year'), identifier = attrs.get('identifier'), plot = toUnicode(attrs.get('plot')), tagline = toUnicode(attrs.get('tagline')), status_id = status.get('id') ) title = LibraryTitle( title = toUnicode(attrs.get('title')), simple_title = self.simplifyTitle(attrs.get('title')), ) l.titles.append(title) db.add(l) db.commit() # Update library info if update_after is not False: handle = fireEventAsync if update_after is 'async' else fireEvent handle('library.update', identifier = l.identifier, default_title = toUnicode(attrs.get('title', ''))) library_dict = l.to_dict(self.default_dict) return library_dict
def add(self, attrs={}): db = get_session() l = db.query(Library).filter_by( identifier=attrs.get('identifier')).first() if not l: l = Library(year=attrs.get('year'), identifier=attrs.get('identifier'), plot=attrs.get('plot'), tagline=attrs.get('tagline')) title = LibraryTitle(title=attrs.get('title')) l.titles.append(title) db.add(l) db.commit() # Update library info fireEventAsync('library.update', library=l, default_title=attrs.get('title', '')) #db.remove() return l
def add(self, attrs=None, update_after=True): if not attrs: attrs = {} primary_provider = attrs.get('primary_provider', 'imdb') try: db = get_session() l = db.query(Library).filter_by( identifier=attrs.get('identifier')).first() if not l: status = fireEvent('status.get', 'needs_update', single=True) l = Library(year=attrs.get('year'), identifier=attrs.get('identifier'), plot=toUnicode(attrs.get('plot')), tagline=toUnicode(attrs.get('tagline')), status_id=status.get('id'), info={}) title = LibraryTitle( title=toUnicode(attrs.get('title')), simple_title=self.simplifyTitle(attrs.get('title')), ) l.titles.append(title) db.add(l) db.commit() # Update library info if update_after is not False: handle = fireEventAsync if update_after is 'async' else fireEvent handle('library.update.movie', identifier=l.identifier, default_title=toUnicode(attrs.get('title', ''))) library_dict = l.to_dict(self.default_dict) return library_dict except: log.error('Failed adding media: %s', traceback.format_exc()) db.rollback() finally: db.close() return {}
def add(self, attrs = None, update_after = True): if not attrs: attrs = {} primary_provider = attrs.get('primary_provider', 'imdb') try: db = get_session() l = db.query(Library).filter_by(identifier = attrs.get('identifier')).first() if not l: status = fireEvent('status.get', 'needs_update', single = True) l = Library( year = attrs.get('year'), identifier = attrs.get('identifier'), plot = toUnicode(attrs.get('plot')), tagline = toUnicode(attrs.get('tagline')), status_id = status.get('id'), info = {} ) title = LibraryTitle( title = toUnicode(attrs.get('title')), simple_title = self.simplifyTitle(attrs.get('title')), ) l.titles.append(title) db.add(l) db.commit() # Update library info if update_after is not False: handle = fireEventAsync if update_after is 'async' else fireEvent handle('library.update.movie', identifier = l.identifier, default_title = toUnicode(attrs.get('title', ''))) library_dict = l.to_dict(self.default_dict) return library_dict except: log.error('Failed adding media: %s', traceback.format_exc()) db.rollback() finally: db.close() return {}
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() 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=None) title = LibraryTitle( title=toUnicode(attrs.get('title')), simple_title=self.simplifyTitle(attrs.get('title')), ) l.titles.append(title) db.add(l) db.commit() # Update library info if update_after is not False: handle = fireEventAsync if update_after is 'async' else fireEvent handle('library.update.movie', identifier=l.identifier, default_title=toUnicode(attrs.get('title', ''))) library_dict = l.to_dict(self.default_dict) db.expire_all() return library_dict
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() 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=None, ) title = LibraryTitle( title=toUnicode(attrs.get("title")), simple_title=self.simplifyTitle(attrs.get("title")) ) l.titles.append(title) db.add(l) db.commit() # Update library info if update_after is not False: handle = fireEventAsync if update_after is "async" else fireEvent handle("library.update.movie", identifier=l.identifier, default_title=toUnicode(attrs.get("title", ""))) library_dict = l.to_dict(self.default_dict) db.expire_all() return library_dict