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