Skip to content

feat: add get_media_gallery() to fetch IMDb media viewer images - #175

Closed
rjriajul wants to merge 1 commit into
tveronesi:developfrom
rjriajul:main
Closed

rjriajul wants to merge 1 commit into
tveronesi:developfrom
rjriajul:main

Conversation

@rjriajul

@rjriajul rjriajul commented Jul 8, 2026 •

Copy link
Copy Markdown

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]

@tveronesi
tveronesi changed the base branch from main to develop July 8, 2026 20:21
@tveronesi

Copy link
Copy Markdown
Owner

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

  1. Open an issue proposing the media gallery feature
  2. Rebase your branch onto develop (not main)
  3. Refactor get_media_gallery() to follow the _get_extended_title_info() pattern
  4. Reference the issue in the PR description
    Happy to discuss the approach further or help with the refactor. Thanks again!

@tveronesi tveronesi closed this Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants