def store_movie(self, data, action, guid, p_key=None, p_movie=None, **kwargs): key = (guid.service, guid.id) movies = dict_path(self.artifacts, [ data, action, 'movies' ]) # Check for duplicate history addition if self._is_duplicate(data, action, p_key): return False # Build movie if key in movies: movie = movies[key] else: movie = self._build_request(guid, p_movie, **kwargs) if movie is None: return False # Store `movie` in artifacts movies[key] = movie # Set `kwargs` on `movie` self._set_kwargs(movie, kwargs) return True
def store_movie(self, data, action, guid, p_key=None, p_movie=None, **kwargs): key = (guid.service, guid.id) movies = dict_path(self.artifacts, [data, action, 'movies']) # Check for duplicate history addition if self._is_duplicate(data, action, p_key): return False # Build movie if key in movies: movie = movies[key] else: movie = self._build_request(guid, p_movie, **kwargs) if movie is None: return False # Store `movie` in artifacts movies[key] = movie # Set `kwargs` on `movie` self._set_kwargs(movie, kwargs) return True
def store_episode(self, data, action, guid, identifier, p_key=None, p_show=None, p_episode=None, **kwargs): key = (guid.service, guid.id) season_num, episode_num = identifier shows = dict_path(self.artifacts, [data, action, 'shows']) # Check for duplicate history addition if self._is_duplicate(data, action, p_key): return False # Build show if key in shows: show = shows[key] else: show = self._build_request(guid, p_show) if show is None: return False shows[key] = show # Ensure 'seasons' attribute exists if 'seasons' not in show: show['seasons'] = {} # Build season if season_num in show['seasons']: season = show['seasons'][season_num] else: season = show['seasons'][season_num] = {'number': season_num} season['episodes'] = {} # Build episode if episode_num in season['episodes']: episode = season['episodes'][episode_num] else: episode = season['episodes'][episode_num] = {'number': episode_num} # Set `kwargs` on `episode` self._set_kwargs(episode, kwargs) return True
def assert_ignored(handler, key, sid, **kwargs): __tracebackhide__ = True # Determine media type artifact_key = get_artifact_key(handler) # Add item handler.on_added(key, Guid.parse('com.plexapp.agents.imdb://%s' % sid), **kwargs) # Ensure item wasn't added item = dict_path(handler.current.artifacts.artifacts, [ SyncData.Collection, 'add', artifact_key, ('imdb', sid) ]) if item != {}: pytest.fail("Artifact found, expected the item to be ignored")
def store_episode(self, data, action, guid, identifier, p_key=None, p_show=None, p_episode=None, **kwargs): key = (guid.service, guid.id) season_num, episode_num = identifier shows = dict_path(self.artifacts, [ data, action, 'shows' ]) # Check for duplicate history addition if self._is_duplicate(data, action, p_key): return False # Build show if key in shows: show = shows[key] else: show = self._build_request(guid, p_show) if show is None: return False shows[key] = show # Ensure 'seasons' attribute exists if 'seasons' not in show: show['seasons'] = {} # Build season if season_num in show['seasons']: season = show['seasons'][season_num] else: season = show['seasons'][season_num] = {'number': season_num} season['episodes'] = {} # Build episode if episode_num in season['episodes']: episode = season['episodes'][episode_num] else: episode = season['episodes'][episode_num] = {'number': episode_num} # Set `kwargs` on `episode` self._set_kwargs(episode, kwargs) return True
def store_show(self, data, action, guid, p_show=None, **kwargs): key = (guid.service, guid.id) shows = dict_path(self.artifacts, [data, action, 'shows']) # Build show if key in shows: show = shows[key] else: show = self._build_request(guid, p_show, **kwargs) if show is None: return False # Store `show` in artifacts shows[key] = show # Set `kwargs` on `show` self._set_kwargs(show, kwargs) return True
def assert_added(handler, key, sid, expected, **kwargs): __tracebackhide__ = True # Determine media type artifact_key = get_artifact_key(handler) # Set default attributes if expected: expected['ids'] = {'imdb': sid} # Add item handler.on_added(key, Guid.parse('com.plexapp.agents.imdb://%s' % sid), **kwargs) # Ensure item was added item = dict_path(handler.current.artifacts.artifacts, [ SyncData.Collection, 'add', artifact_key, ('imdb', sid) ]) if item != expected: pytest.fail("Artifact %r doesn't match the expected item %r" % (item, expected))
def store_show(self, data, action, guid, p_show=None, **kwargs): key = (guid.service, guid.id) shows = dict_path(self.artifacts, [ data, action, 'shows' ]) # Build show if key in shows: show = shows[key] else: show = self._build_request(guid, p_show, **kwargs) if show is None: return False # Store `show` in artifacts shows[key] = show # Set `kwargs` on `show` self._set_kwargs(show, kwargs) return True