itsmehemant7 / PyMovieDb

A Simple IMDb API for Python
MIT License
90 stars 18 forks source link

Feature request: Add Country of origin and Language #24

Open cvjensen opened 3 months ago

cvjensen commented 3 months ago

Is it possible to make PyMovieDb return Country of origin and Language also?

cvjensen commented 3 months ago

I found this

response.html.xpath("//script[@id='__NEXT_DATA__']")[0].text

that returns ALOOOT more data like

            nextdata = response.html.xpath("//script[@id='__NEXT_DATA__']")[0].text
            nextdata = ''.join(nextdata.splitlines())  # removing newlines
            nextdata = f"""{nextdata}"""
            nextdata = json.loads(nextdata)
            #print(json.dumps(nextdata, indent=2))
            countries = [country['id'] for country in nextdata['props']['pageProps']['mainColumnData']['countriesOfOrigin']['countries']]
            print(countries)

            languages = [language['id'] for language in nextdata['props']['pageProps']['mainColumnData']['spokenLanguages']['spokenLanguages']]
            print(languages)
python test.py
['US']
['en']