def get(self, name): """ Looks up the given name in the scene_names table in cache db :param name: The show name to look up. :return: the TVDB id that resulted from the cache lookup or None if the show wasn't found in the cache """ name = full_sanitize_scene_name(name) if name in self.cache: return int(self.cache[name])
def check_against_names(name_in_question, show, season=-1): show_names = [] if season in [-1, 1]: show_names = [show.name] show_names.extend(get_scene_exceptions(show.indexer_id, season=season)) for showName in show_names: name_from_list = full_sanitize_scene_name(showName) if name_from_list == name_in_question: return True return False
def put(self, name, indexer_id=0, session=None): """ Adds the show & tvdb id to the scene_names table in cache db :param name: The show name to cache :param indexer_id: the TVDB id that this show should be cached with (can be None/0 for unknown) """ # standardize the name we're using to account for small differences in providers name = full_sanitize_scene_name(name) self.cache[name] = int(indexer_id) try: session.query(CacheDB.SceneName).filter_by( name=name, indexer_id=indexer_id).one() except orm.exc.NoResultFound: session.add( CacheDB.SceneName(**{ 'indexer_id': indexer_id, 'name': name }))