def __init__(self, recipe_name, sort_only=False, config_file=None): self.recipe_name = recipe_name self.config = ConfigParser(config_file) self.recipe = RecipeParser(recipe_name) if self.recipe['library_type'].lower().startswith('movie'): self.library_type = 'movie' elif self.recipe['library_type'].lower().startswith('tv'): self.library_type = 'tv' else: raise Exception("Library type should be 'movie' or 'tv'") # TODO: Support multiple libraries self.source_library_config = self.recipe['source_libraries'] self.plex = plexutils.Plex(self.config['plex']['baseurl'], self.config['plex']['token']) if self.config['trakt']['username']: self.trakt = traktutils.Trakt( self.config['trakt']['username'], client_id=self.config['trakt']['client_id'], client_secret=self.config['trakt']['client_secret']) if self.config['tmdb']['api_key']: self.tmdb = tmdb.TMDb(self.config['tmdb']['api_key'], cache_file=self.config['tmdb']['cache_file']) if self.config['tvdb']['username']: self.tvdb = tvdb.TheTVDB(self.config['tvdb']['username'], self.config['tvdb']['api_key'], self.config['tvdb']['user_key'])
def __init__(self, recipe_name, sort_only=False, config_file=None, use_playlists=False): self.recipe_name = recipe_name self.use_playlists = use_playlists self.config = ConfigParser(config_file) self.recipe = RecipeParser(recipe_name) if not self.config.validate(): raise Exception("Error(s) in config") if not self.recipe.validate(use_playlists=use_playlists): raise Exception("Error(s) in recipe") if self.recipe['library_type'].lower().startswith('movie'): self.library_type = 'movie' elif self.recipe['library_type'].lower().startswith('tv'): self.library_type = 'tv' else: raise Exception("Library type should be 'movie' or 'tv'") self.source_library_config = self.recipe['source_libraries'] self.plex = plexutils.Plex(self.config['plex']['baseurl'], self.config['plex']['token']) if self.config['trakt']['username']: self.trakt = traktutils.Trakt( self.config['trakt']['username'], client_id=self.config['trakt']['client_id'], client_secret=self.config['trakt']['client_secret'], oauth_token=self.config['trakt'].get('oauth_token', ''), oauth=self.recipe.get('trakt_oauth', False), config=self.config) if self.trakt.oauth_token: self.config['trakt']['oauth_token'] = self.trakt.oauth_token if self.config['tmdb']['api_key']: self.tmdb = tmdb.TMDb(self.config['tmdb']['api_key'], cache_file=self.config['tmdb']['cache_file']) if self.config['tvdb']['username']: self.tvdb = tvdb.TheTVDB(self.config['tvdb']['username'], self.config['tvdb']['api_key'], self.config['tvdb']['user_key']) self.imdb = imdbutils.IMDb(self.tmdb, self.tvdb) self.source_map = IdMap(matching_only=True, cache_file=self.config.get('guid_cache_file')) self.dest_map = IdMap(cache_file=self.config.get('guid_cache_file'))
def __init__(self, recipe_name, config_file=None): self.recipe_name = recipe_name self.config = ConfigParser(config_file) self.recipe = RecipeParser(recipe_name) if self.recipe['library_type'].lower().startswith('movie'): self.library_type = 'movie' elif self.recipe['library_type'].lower().startswith('tv'): self.library_type = 'tv' else: raise Exception("Library type should be 'movie' or 'tv'") self.source_library_config = self.recipe['source_libraries'] self.plex = plexutils.Plex(self.config['plex']['baseurl'], self.config['plex']['token']) if self.config['trakt']['username']: self.trakt = traktutils.Trakt( self.config['trakt']['username'], client_id=self.config['trakt']['client_id'], client_secret=self.config['trakt']['client_secret'], oauth_token=self.config['trakt'].get('oauth_token', ''), oauth=self.recipe.get('trakt_oauth', False), config=self.config) if self.trakt.oauth_token: self.config['trakt']['oauth_token'] = self.trakt.oauth_token if self.config['tmdb']['api_key']: self.tmdb = tmdb.TMDb(self.config['tmdb']['api_key'], cache_file=self.config['tmdb']['cache_file']) if self.config['tvdb']['username']: self.tvdb = tvdb.TheTVDB(self.config['tvdb']['username'], self.config['tvdb']['api_key'], self.config['tvdb']['user_key']) self.imdb = imdbutils.IMDb(self.tmdb, self.tvdb)