@@ 234-261 (lines=28) @@ | ||
231 | self._set_kwargs(episode, kwargs) |
|
232 | return True |
|
233 | ||
234 | def store_movie(self, data, action, guid, p_key=None, p_movie=None, **kwargs): |
|
235 | key = (guid.service, guid.id) |
|
236 | ||
237 | movies = dict_path(self.artifacts, [ |
|
238 | data, |
|
239 | action, |
|
240 | 'movies' |
|
241 | ]) |
|
242 | ||
243 | # Check for duplicate history addition |
|
244 | if self._is_duplicate(data, action, p_key): |
|
245 | return False |
|
246 | ||
247 | # Build movie |
|
248 | if key in movies: |
|
249 | movie = movies[key] |
|
250 | else: |
|
251 | movie = self._build_request(guid, p_movie, **kwargs) |
|
252 | ||
253 | if movie is None: |
|
254 | return False |
|
255 | ||
256 | # Store `movie` in artifacts |
|
257 | movies[key] = movie |
|
258 | ||
259 | # Set `kwargs` on `movie` |
|
260 | self._set_kwargs(movie, kwargs) |
|
261 | return True |
|
262 | ||
263 | @classmethod |
|
264 | def _build_request(cls, guid, p_item, **kwargs): |
|
@@ 163-186 (lines=24) @@ | ||
160 | # Artifact storage |
|
161 | # |
|
162 | ||
163 | def store_show(self, data, action, guid, p_show=None, **kwargs): |
|
164 | key = (guid.service, guid.id) |
|
165 | ||
166 | shows = dict_path(self.artifacts, [ |
|
167 | data, |
|
168 | action, |
|
169 | 'shows' |
|
170 | ]) |
|
171 | ||
172 | # Build show |
|
173 | if key in shows: |
|
174 | show = shows[key] |
|
175 | else: |
|
176 | show = self._build_request(guid, p_show, **kwargs) |
|
177 | ||
178 | if show is None: |
|
179 | return False |
|
180 | ||
181 | # Store `show` in artifacts |
|
182 | shows[key] = show |
|
183 | ||
184 | # Set `kwargs` on `show` |
|
185 | self._set_kwargs(show, kwargs) |
|
186 | return True |
|
187 | ||
188 | def store_episode(self, data, action, guid, identifier, p_key=None, p_show=None, p_episode=None, **kwargs): |
|
189 | key = (guid.service, guid.id) |