parent
9d9d747b72
commit
013a1bfa8a
1 changed files with 3 additions and 4 deletions
|
|
@ -1,6 +1,5 @@
|
||||||
import requests
|
import requests
|
||||||
import gettext
|
import gettext
|
||||||
import pkg_resources
|
|
||||||
import os
|
import os
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
@ -90,7 +89,8 @@ class YTMusic(BrowsingMixin, WatchMixin, ExploreMixin, LibraryMixin, PlaylistsMi
|
||||||
# prepare context
|
# prepare context
|
||||||
self.context = initialize_context()
|
self.context = initialize_context()
|
||||||
self.context['context']['client']['hl'] = language
|
self.context['context']['client']['hl'] = language
|
||||||
supported_languages = [f for f in pkg_resources.resource_listdir('ytmusicapi', 'locales')]
|
locale_dir = os.path.abspath(os.path.dirname(__file__)) + os.sep + 'locales'
|
||||||
|
supported_languages = [f for f in os.listdir(locale_dir)]
|
||||||
if language not in supported_languages:
|
if language not in supported_languages:
|
||||||
raise Exception("Language not supported. Supported languages are "
|
raise Exception("Language not supported. Supported languages are "
|
||||||
', '.join(supported_languages))
|
', '.join(supported_languages))
|
||||||
|
|
@ -101,8 +101,7 @@ class YTMusic(BrowsingMixin, WatchMixin, ExploreMixin, LibraryMixin, PlaylistsMi
|
||||||
with suppress(locale.Error):
|
with suppress(locale.Error):
|
||||||
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
|
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
|
||||||
self.lang = gettext.translation('base',
|
self.lang = gettext.translation('base',
|
||||||
localedir=pkg_resources.resource_filename(
|
localedir=locale_dir,
|
||||||
'ytmusicapi', 'locales'),
|
|
||||||
languages=[language])
|
languages=[language])
|
||||||
self.parser = browsing.Parser(self.lang)
|
self.parser = browsing.Parser(self.lang)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue