def retrieveNameFromCache(name): """ Look 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 name_cache: return int(name_cache[name])
def retrieveNameFromCache(name): """ Look up the given name in the scene_names table in cache.db. :param name: The show name to look up. :return: Return a tuple with two items. First: indexer_id, Second: series_id. """ name = full_sanitize_scene_name(name) if name in name_cache: return name_cache[name] return None, None
def _cache_name(cache_series_obj): """Build the name cache for a single show.""" clear_cache(cache_series_obj.indexer, cache_series_obj.series_id) series_identifier = (cache_series_obj.indexer, cache_series_obj.series_id) scene_exceptions = exceptions_cache[series_identifier].copy() names = { full_sanitize_scene_name(name): series_identifier for season_exceptions in itervalues(scene_exceptions) for name in season_exceptions } # Add original name to name cache series_name = full_sanitize_scene_name(cache_series_obj.name) names[series_name] = series_identifier # Add scene exceptions to name cache name_cache.update(names) log.debug(u'Internal name cache for {series} set to: {names}', { 'series': series_name, 'names': u', '.join(list(names)) })
def _cache_name(show): """Build the name cache for a single show.""" indexer_id = show.indexerid clear_cache(indexer_id) scene_exceptions = exceptions_cache[indexer_id].copy() names = { full_sanitize_scene_name(name): int(indexer_id) for season_exceptions in scene_exceptions.values() for name in season_exceptions } # Add original name to name cache show_name = full_sanitize_scene_name(show.name) names[show_name] = indexer_id # Add scene exceptions to name cache name_cache.update(names) log.debug(u'Internal name cache for {show} set to: {names}', { 'show': show.name, 'names': ', '.join(names.keys()) })
def addNameToCache(name, indexer_id=1, series_id=0): """ Add the show & tvdb id to the scene_names table in cache.db. :param name: The show name to cache :param indexer_id: the indexer's id. :param series_id: the TVDB id that this show should be cached with (can be None/0 for unknown) """ cache_db_con = db.DBConnection('cache.db') # standardize the name we're using to account for small differences in providers name = full_sanitize_scene_name(name) if name not in name_cache: name_cache[name] = (indexer_id, series_id) cache_db_con.action('INSERT OR REPLACE INTO scene_names (indexer_id, name, indexer) VALUES (?, ?, ?)', [series_id, name, indexer_id])