tombulled / innertube

Python Client for Google's Private InnerTube API. Works with YouTube, YouTube Music and more!
https://pypi.org/project/innertube/
MIT License
298 stars 20 forks source link

Locale parameter doesn't work #75

Open kms0219kms opened 4 months ago

kms0219kms commented 4 months ago

Problem

A request was sent using the following locale parameters:

yt = InnerTube(client_name="WEB", locale=Locale(hl="ko-KR", gl="ko"))

But the result is still in English.

Solution

As far as I know, hl and gl should also be passed in the context of the request body, like this: image

So we need to add hl and gl parameters to the models.py -> contextualize function to make the locale parameter work.

Notes

However, the format of the Accept Language header is "xx-XX,xx;q=0.5", but the format of the context parameter is 'xx' for hl and 'XX' for gl. We need to think about how to apply both to the models.py -> Locale class.