remove context.json

This commit is contained in:
sigma67 2021-04-28 16:35:16 +02:00
commit 90a12774a5
No known key found for this signature in database
GPG key ID: 1545A01D4474BAF0
4 changed files with 13 additions and 46 deletions

View file

@ -1,4 +1,3 @@
include README.md
recursive-include ytmusicapi/locales *.mo
include ytmusicapi/*.json
recursive-include ytmusicapi *.py

View file

@ -1,42 +0,0 @@
{
"context": {
"capabilities": {},
"client": {
"clientName": "WEB_REMIX",
"clientVersion": "0.1",
"experimentIds": [],
"experimentsToken": "",
"gl": "DE",
"hl": "en",
"locationInfo": {
"locationPermissionAuthorizationStatus": "LOCATION_PERMISSION_AUTHORIZATION_STATUS_UNSUPPORTED"
},
"musicAppInfo": {
"musicActivityMasterSwitch": "MUSIC_ACTIVITY_MASTER_SWITCH_INDETERMINATE",
"musicLocationMasterSwitch": "MUSIC_LOCATION_MASTER_SWITCH_INDETERMINATE",
"pwaInstallabilityStatus": "PWA_INSTALLABILITY_STATUS_UNKNOWN"
},
"utcOffsetMinutes": 60
},
"request": {
"internalExperimentFlags": [
{
"key": "force_music_enable_outertube_tastebuilder_browse",
"value": "true"
},
{
"key": "force_music_enable_outertube_playlist_detail_browse",
"value": "true"
},
{
"key": "force_music_enable_outertube_search_suggestions",
"value": "true"
}
],
"sessionIndex": {}
},
"user": {
"enableSafetyMode": false
}
}
}

View file

@ -58,6 +58,18 @@ def initialize_headers():
}
def initialize_context():
return {
'context': {
'client': {
'clientName': 'WEB_REMIX',
'clientVersion': '0.1'
},
'user': {}
}
}
def get_visitor_id(request_func):
response = request_func(YTM_DOMAIN)
matches = re.findall(r'ytcfg\.set\s*\(\s*({.+?})\s*\)\s*;', response)

View file

@ -87,9 +87,7 @@ class YTMusic(BrowsingMixin, WatchMixin, LibraryMixin, PlaylistsMixin, UploadsMi
self.headers.update(get_visitor_id(self._send_get_request))
# prepare context
with open(pkg_resources.resource_filename('ytmusicapi', 'context.json')) as json_file:
self.context = json.load(json_file)
self.context = initialize_context()
self.context['context']['client']['hl'] = language
supported_languages = [f for f in pkg_resources.resource_listdir('ytmusicapi', 'locales')]
if language not in supported_languages: