Kometa-Team / TMDbAPIs

A lightweight Python library for TMDb V3 and V4 APIs.
https://tmdbapis.metamanager.wiki
MIT License
11 stars 0 forks source link

fix property mismatch between _language and language #6

Closed mchangrh closed 1 year ago

mchangrh commented 1 year ago

Description

Fixed property mismatch between self._language and self.language

Issues Fixed or Closed

Type of Change

Checklist

Explanation

TMDb specifies that language defaults to en-US but that is incorrect, it defaults to None/null.

This is reflected correctly in the raw API https://github.com/meisnate12/TMDbAPIs/blob/7f790278b62da0b92da93832f59c01831c82d7a1/tmdbapis/api3.py#L2192-L2195

but not in the object API https://github.com/meisnate12/TMDbAPIs/blob/7f790278b62da0b92da93832f59c01831c82d7a1/tmdbapis/tmdb.py#L61-L84

self._language is correctly set to initialize to None, which makes it able to pull from all languages, but the property queried for the locale to be passed through is self.language, which is incorrectly set to initialize to "en" None is an invalid language, making it impossible to query for backdrops without languages, or query by all languages as seen in #5

also the language getter/setter targeted _language which was never queried, instead of language

mchangrh commented 1 year ago

MCVE to demonstrate the differences between APIs.

from tmdbapis import TMDbAPIs, api3

apikey = ""
tvid = 202102

objapi = TMDbAPIs(apikey)
obj_show = objapi.tv_show(tvid)

rawapi = api3.API3(apikey)
raw_show = rawapi.tv_get_images(tvid)

def path_only(backdrop):
    return backdrop['file_path'], backdrop['iso_639_1']

print("obj backdrops")
print(obj_show.backdrops)
print("raw backdrops")
print(list(map(path_only, raw_show['backdrops'])))
obj backdrops
[[Backdrop:/1LeXSX1Z7PsWmb4x6SRB61c4dfk.jpg], [Backdrop:/gewfanBcat8DC8hG9rZ64bYI6W2.jpg], [Backdrop:/sj1UGxYusH3oPxNkR0JuJj1eHed.jpg], [Backdrop:/urfRutUKyn4hywQvYS7k0SEzfnT.jpg], [Backdrop:/2wiqHO9l9qoCr9ERDwA1LULsQxd.jpg]]
raw backdrops
[('/aAwtr0pj9jt3DnhTNltOoaOrnk1.jpg', None), ('/1LeXSX1Z7PsWmb4x6SRB61c4dfk.jpg', 'en'), ('/gewfanBcat8DC8hG9rZ64bYI6W2.jpg', 'en'), ('/3R38NDSDituhQDxy24SYG1Q7j9c.jpg', None), ('/sj1UGxYusH3oPxNkR0JuJj1eHed.jpg', 'en'), ('/urfRutUKyn4hywQvYS7k0SEzfnT.jpg', 'en'), ('/2wiqHO9l9qoCr9ERDwA1LULsQxd.jpg', 'en'), ('/c0hBEOLW0CJFELk72BtUdaa3kV2.jpg', None), ('/pz4NEoIn8RHtHqGOXGLejy7hoRt.jpg', None)]
mchangrh commented 1 year ago

Converting to issue as the PR does not properly address the problem