You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: add get_media_gallery() to fetch IMDb media viewer images - #175
This pull request adds support for retrieving and parsing media galleries (such as images and posters) for IMDb titles. It introduces new models, parsing logic, and service methods to handle media galleries, and includes comprehensive tests to verify the new functionality.
Media Gallery Support
Added new models MediaItem and MediaGallery in imdbinfo/models.py to represent individual media items and galleries, including fields for image metadata, captions, sources, and associated names/titles.
Implemented the parse_json_media_gallery function in imdbinfo/parsers.py to extract media gallery data from IMDb API responses, returning a MediaGallery instance or None if no images are present.
Added the get_media_gallery service function in imdbinfo/services.py to fetch and cache media gallery data for a given IMDb title, using a GraphQL query and returning a parsed MediaGallery object.
Public API and Imports
Exposed get_media_gallery, MediaItem, and MediaGallery in the package’s public API by updating imdbinfo/__init__.py and relevant import statements in other modules. [1][2][3][4][5]
Testing
Added extensive tests for media gallery parsing and service logic in tests/test_parsers.py and tests/test_services.py, covering normal cases, edge cases, and caching behavior. [1][2]
Hi! First of all, thanks for the contribution - the idea of adding a media gallery feature is great, and we appreciate you taking the time to implement it.
Unfortunately, I can't approve this PR as-is. There are a few issues that need to be addressed before it can be merged:
1. Incorrect target branch
The PR was opened against main, but the active development branch is develop. This has pulled in unrelated changes (removal of year/exact_match params from search_title(), changes to SeasonEpisodesList.__str__). Please rebase your PR onto develop so it only contains your changes.
2. GraphQL query should go through _get_extended_title_info()
The project has an established pattern: all extended title info (AKAs, trivia, reviews, parental guide, interests) is fetched through a single cached helper _get_extended_title_info(). Your get_media_gallery() function makes its own separate GraphQL request instead. This means:
Each call to get_media_gallery() makes a duplicate HTTP request even if other title data was already fetched
It doesn't benefit from the @lru_cache caching that other functions get
The correct approach is:
Add the images query to _get_extended_title_info()
Have get_media_gallery() call _get_extended_title_info() and extract the images from the result, just like get_akas(), get_trivia(), etc. do
3. PR must reference an issue
Per our CONTRIBUTING.md, all PRs must be tied to a previously discussed issue. Could you open an issue first describing the feature, and reference it in the PR?
What to do next
Open an issue proposing the media gallery feature
Rebase your branch onto develop (not main)
Refactor get_media_gallery() to follow the _get_extended_title_info() pattern
Reference the issue in the PR description
Happy to discuss the approach further or help with the refactor. Thanks again!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds support for retrieving and parsing media galleries (such as images and posters) for IMDb titles. It introduces new models, parsing logic, and service methods to handle media galleries, and includes comprehensive tests to verify the new functionality.
Media Gallery Support
MediaItemandMediaGalleryinimdbinfo/models.pyto represent individual media items and galleries, including fields for image metadata, captions, sources, and associated names/titles.parse_json_media_galleryfunction inimdbinfo/parsers.pyto extract media gallery data from IMDb API responses, returning aMediaGalleryinstance orNoneif no images are present.get_media_galleryservice function inimdbinfo/services.pyto fetch and cache media gallery data for a given IMDb title, using a GraphQL query and returning a parsedMediaGalleryobject.Public API and Imports
get_media_gallery,MediaItem, andMediaGalleryin the package’s public API by updatingimdbinfo/__init__.pyand relevant import statements in other modules. [1] [2] [3] [4] [5]Testing
tests/test_parsers.pyandtests/test_services.py, covering normal cases, edge cases, and caching behavior. [1] [2]