Skip to content

feat: add translated logo with tmdb#118

Open
chaffy999 wants to merge 1 commit intoTimilsinaBimal:mainfrom
chaffy999:feature/translated-logo
Open

feat: add translated logo with tmdb#118
chaffy999 wants to merge 1 commit intoTimilsinaBimal:mainfrom
chaffy999:feature/translated-logo

Conversation

@chaffy999
Copy link
Contributor

No description provided.

@vercel
Copy link

vercel bot commented Mar 14, 2026

@chaffy999 is attempting to deploy a commit to the Bimal Timilsina's projects Team on Vercel.

A member of the Team first needs to authorize it.

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces significant enhancements to how media metadata, specifically logos, posters, and backgrounds, are handled by integrating with The Movie Database (TMDB) for language-specific assets. A new API endpoint has been added to expose this functionality, allowing clients to request media images tailored to a specific language. The existing metadata processing has been updated to leverage these new TMDB capabilities, ensuring that translated logos are prioritized and displayed when available, improving the localization and user experience.

Highlights

  • New API Endpoint for Meta Images: A new API endpoint, /api/meta/images, has been added to allow fetching language-specific logos, posters, and backgrounds for movies and series using TMDB IDs or IMDb IDs.
  • TMDB Image Integration: The TMDB service has been extended with new methods to fetch, cache, and intelligently select images based on language preferences, including fallbacks for English and language-neutral assets.
  • Localized Logo Prioritization: Metadata processing has been updated to prioritize language-specific logos retrieved from TMDB over generic Metahub logos, enhancing localization for Stremio metadata.
  • Enhanced Metadata Formatting: The format_for_stremio method now accepts an optional logo_url parameter, allowing for the direct inclusion of language-specific logos into the formatted metadata.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • app/api/endpoints/meta.py
    • Imported Query for API parameter validation.
    • Added /api/meta/images endpoint to fetch localized media images.
    • Implemented logic to convert IMDb IDs to TMDB IDs and handle media types.
    • Included error handling for fetching images from TMDB.
  • app/services/recommendation/catalog_service.py
    • Included 'logo' in the list of metadata keys to clean.
    • Modified logo assignment to conditionally use Metahub URL only if a TMDB logo is not already present.
  • app/services/recommendation/metadata.py
    • Modified format_for_stremio to accept an optional logo_url parameter.
    • Incorporated the provided logo_url into the formatted metadata.
    • Added asynchronous fetching of images for multiple titles using the new TMDB service methods.
    • Passed fetched logo_url to format_for_stremio during batch processing.
  • app/services/tmdb/service.py
    • Implemented get_images method to fetch raw image data from TMDB with language filtering and caching.
    • Added _pick_image_by_language static method for selecting the best image based on language preference.
    • Created _language_to_image_preference method to generate language preference lists and API parameters.
    • Developed get_images_for_title to fetch, process, and return localized poster, logo, and background URLs.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new feature to fetch translated logos, posters, and backgrounds from TMDB, exposing them through a new API endpoint and integrating them into the recommendation catalog. The implementation is mostly solid, but I've found a significant logical bug in the batch processing of metadata that would prevent the feature from working correctly in all cases. I've also included a minor suggestion to improve code readability in the image selection logic. Addressing the bug is important for the feature's correctness.

Comment on lines +171 to +183
image_tasks = [_images_one(d) for d in details_list if d]
images_list = await asyncio.gather(*image_tasks, return_exceptions=True)

format_task = []
for i, details in enumerate(details_list):
if not details:
continue
logo_url = None
if i < len(images_list):
imgs = images_list[i]
if isinstance(imgs, dict):
logo_url = imgs.get("logo") or None
format_task.append(cls.format_for_stremio(details, media_type, user_settings, logo_url=logo_url))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

There is a logic error in how details_list is correlated with images_list. images_list is created from a filtered version of details_list (where details is not None), making it potentially shorter. The current loop iterates over details_list with an index i, and uses i to access images_list. This will fail to assign logos for items that appear after a failed detail fetch in the details_list.

To fix this and improve readability, it's better to create a list of successful details first, fetch images for them, and then use zip to iterate over both lists together.

        successful_details = [d for d in details_list if d]
        image_tasks = [_images_one(d) for d in successful_details]
        images_list = await asyncio.gather(*image_tasks, return_exceptions=True)

        format_task = []
        for details, imgs in zip(successful_details, images_list):
            logo_url = None
            if isinstance(imgs, dict):
                logo_url = imgs.get("logo")
            format_task.append(cls.format_for_stremio(details, media_type, user_settings, logo_url=logo_url))

for lang in preferred_lang_codes:
for img in images_list:
iso = img.get("iso_639_1")
if (iso or None) == (lang if lang else None):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The condition to check for language equality can be simplified for better readability. The expressions (iso or None) and (lang if lang else None) are redundant. iso (from img.get(...)) and lang are already effectively str | None, so a direct comparison iso == lang is sufficient and clearer.

Suggested change
if (iso or None) == (lang if lang else None):
if iso == lang:

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.

1 participant