xbmc / xbmc/metadata.themoviedb.org.python
Feature request: optional fallback certification country when preferred country has no rating
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 60
- Forks
- 50
- Avg merge
- 11h 38m
- Merged PRs (30d)
- 1
Description
Problem
When Preferred Certification Country is set to a country like nl (Netherlands), many movies have no certification on TMDB for that country. The MPAA/age rating field in Kodi is left completely empty — even though certifications for other countries (e.g. US) exist in the same API response.
I prefer NL ratings when they're available, but a fallback to another country would be much better than no rating at all.
Proposed Solution
Add an optional Fallback Certification Country dropdown in settings. When the primary country has no certification, check the fallback country. Fully user-selectable, not hardcoded. If disabled (empty), behavior is unchanged from today.
No extra API calls needed — the releases.countries array already contains all countries in a single response.
Implementation
Complete diffs for all files involved:
1. resources/language/resource.language.en_gb/strings.po — add label
After the #30018 entry, add:
msgctxt "#30019"
msgid "Fallback Certification Country"
msgstr ""
2. resources/settings.xml — add setting after tmdbcertcountry (line 216)
Insert between the closing </setting> of tmdbcertcountry and the opening of certprefix:
<setting id="tmdbcertcountry_fallback" type="string" label="30019" help="">
<level>0</level>
<default/>
<constraints>
<allowempty>true</allowempty>
<options>
<option>au</option>
<option>bg</option>
<option>br</option>
<option>by</option>
<option>ca</option>
<option>cz</option>
<option>ge</option>
<option>de</option>
<option>dk</option>
<option>ee</option>
<option>es</option>
<option>fi</option>
<option>fr</option>
<option>gb</option>
<option>gr</option>
<option>hr</option>
<option>hu</option>
<option>id</option>
<option>il</option>
<option>in</option>
<option>it</option>
<option>ir</option>
<option>jp</option>
<option>kr</option>
<option>lt</option>
<option>lv</option>
<option>mx</option>
<option>nl</option>
<option>no</option>
<option>pl</option>
<option>pt</option>
<option>ru</option>
<option>si</option>
<option>sv</option>
<option>th</option>
<option>tr</option>
<option>ua</option>
<option>us</option>
<option>vn</option>
<option>zh</option>
</options>
</constraints>
<control type="list" format="string">
<heading>30019</heading>
</control>
</setting>
3. python/scraper.py — read and pass fallback setting (lines 23-27)
def get_tmdb_scraper(settings):
language = settings.getSettingString('language')
certcountry = settings.getSettingString('tmdbcertcountry')
+ certcountry_fallback = settings.getSettingString('tmdbcertcountry_fallback')
search_language = settings.getSettingString('searchlanguage')
- return TMDBMovieScraper(ADDON_SETTINGS, language, certcountry, search_language)
+ return TMDBMovieScraper(ADDON_SETTINGS, language, certcountry, search_language, certcountry_fallback)
4. python/lib/tmdbscraper/tmdb.py — constructor + fallback logic
Constructor (line 5):
- def __init__(self, url_settings, language, certification_country, search_language=""):
+ def __init__(self, url_settings, language, certification_country, search_language="", certification_country_fallback=""):
Add after line 8:
self.certification_country_fallback = certification_country_fallback
Certification extraction (lines 122-127):
if 'countries' in movie['releases']:
certcountry = self.certification_country.upper()
for country in movie['releases']['countries']:
if country['iso_3166_1'] == certcountry and country['certification']:
info['mpaa'] = country['certification']
break
+ if 'mpaa' not in info and self.certification_country_fallback:
+ certcountry_fallback = self.certification_country_fallback.upper()
+ for country in movie['releases']['countries']:
+ if country['iso_3166_1'] == certcountry_fallback and country['certification']:
+ info['mpaa'] = country['certification']
+ break
All diffs verified against current master (v3.2.0). Existing tests will continue to pass since the fallback defaults to empty string (disabled).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with resources/settings.xml and resources/language/resource.language.en_gb/strings.po to review the new setting, then follow python/scraper.py into python/lib/tmdbscraper/tmdb.py. Verify that the preferred country remains first choice, the fallback is used only when needed, an empty fallback preserves current behavior, and the existing tests continue to pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100