-
Notifications
You must be signed in to change notification settings - Fork 0
feat: batch fetch Plex items #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -316,25 +316,24 @@ async def _augment_episode( | |
| results: List[AggregatedItem] = [] | ||
| async with httpx.AsyncClient(timeout=30) as client: | ||
| movie_section = server.library.section("Movies") | ||
| movie_tasks = [ | ||
| _augment_movie(client, movie.fetchItem(movie.ratingKey)) | ||
| for movie in movie_section.all() | ||
| ] | ||
| movie_keys = [int(m.ratingKey) for m in movie_section.all()] | ||
| movies = server.fetchItems(movie_keys) if movie_keys else [] | ||
| movie_tasks = [_augment_movie(client, movie) for movie in movies] | ||
| if movie_tasks: | ||
| results.extend(await _gather_in_batches(movie_tasks, batch_size)) | ||
|
|
||
| show_section = server.library.section("TV Shows") | ||
| for show in show_section.all(): | ||
| full_show = show.fetchItem(show.ratingKey) | ||
| show_keys = [int(s.ratingKey) for s in show_section.all()] | ||
| full_shows = server.fetchItems(show_keys) if show_keys else [] | ||
| for full_show in full_shows: | ||
| show_ids = _extract_external_ids(full_show) | ||
| show_tmdb: Optional[TMDBShow] = None | ||
| if show_ids.tmdb: | ||
| show_tmdb = await _fetch_tmdb_show(client, show_ids.tmdb, tmdb_api_key) | ||
| episode_keys = [int(e.ratingKey) for e in full_show.episodes()] | ||
|
Comment on lines
+319
to
+333
|
||
| episodes = server.fetchItems(episode_keys) if episode_keys else [] | ||
| episode_tasks = [ | ||
| _augment_episode( | ||
| client, episode.fetchItem(episode.ratingKey), show_tmdb | ||
| ) | ||
| for episode in full_show.episodes() | ||
| _augment_episode(client, episode, show_tmdb) for episode in episodes | ||
| ] | ||
| if episode_tasks: | ||
| results.extend(await _gather_in_batches(episode_tasks, batch_size)) | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.