@with_session
def get_cached(style=None, title=None, year=None, trakt_id=None, trakt_slug=None, tmdb_id=None, imdb_id=None, tvdb_id=None, tvrage_id=None, session=None):
 ids = {u'id': trakt_id, u'slug': trakt_slug, u'tmdb_id': tmdb_id, u'imdb_id': imdb_id}
 if (style == u'show'):
  ids[u'tvdb_id'] = tvdb_id
  ids[u'tvrage_id'] = tvrage_id
  model = TraktShow
 else:
  model = TraktMovie
 result = None
 if any(ids.values()):
  result = session.query(model).filter(or_(((getattr(model, col) == val) for (col, val) in ids.items() if val))).first()
 elif title:
  (title, y) = split_title_year(title)
  year = (year or y)
  query = session.query(model).filter((model.title == title))
  if year:
   query = query.filter((model.year == year))
  result = query.first()
 return result

@ with_session def get_cached ( style = None , title = None , year = None , trakt_id = None , trakt_slug = None , tmdb_id = None , imdb_id = None , tvdb_id = None , tvrage_id = None , session = None ) : ids = { u'id' : trakt_id , u'slug' : trakt_slug , u'tmdb_id' : tmdb_id , u'imdb_id' : imdb_id } if ( style == u'show' ) : ids [ u'tvdb_id' ] = tvdb_id ids [ u'tvrage_id' ] = tvrage_id model = TraktShow else : model = TraktMovie result = None if any ( ids . values ( ) ) : result = session . query ( model ) . filter ( or_ ( ( ( getattr ( model , col ) == val ) for ( col , val ) in ids . items ( ) if val ) ) ) . first ( ) elif title : ( title , y ) = split_title_year ( title ) year = ( year or y ) query = session . query ( model ) . filter ( ( model . title == title ) ) if year : query = query . filter ( ( model . year == year ) ) result = query . first ( ) return result
get the cached info for a given show/movie from the database .