From c64a4a606d5a2ab534a2947871a532b27be3262c Mon Sep 17 00:00:00 2001 From: Marshal Date: Thu, 26 Dec 2019 12:01:17 +0300 Subject: [PATCH] =?UTF-8?q?=20=D0=A3=D0=B1=D1=80=D0=B0=D0=BD=D0=BE=20?= =?UTF-8?q?=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B7=D0=B0=D1=80=D0=B5=D0=B7=D0=B5=D1=80?= =?UTF-8?q?=D0=B2=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20?= =?UTF-8?q?=D0=B8=D0=BC=D1=91=D0=BD=20=D0=B2=20=D0=B0=D1=80=D0=B3=D1=83?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D1=85=20=D0=BA=D0=BE=D0=BD=D1=81?= =?UTF-8?q?=D1=82=D1=80=D1=83=D0=BA=D1=82=D0=BE=D1=80=D0=BE=D0=B2=20#168?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yandex_music/utils/request.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/yandex_music/utils/request.py b/yandex_music/utils/request.py index 49911b2..76d7805 100644 --- a/yandex_music/utils/request.py +++ b/yandex_music/utils/request.py @@ -1,12 +1,14 @@ import re import logging -import requests +import builtins # Не используется ujson из-за отсутствия в нём object_hook'a # Отправка вообще application/x-www-form-urlencoded, а не JSON'a # https://github.com/psf/requests/blob/master/requests/models.py#L508 import json +import requests + from yandex_music.utils.captcha_response import CaptchaResponse from yandex_music.utils.response import Response from yandex_music.exceptions import Unauthorized, BadRequest, NetworkError, YandexMusicError, CaptchaRequired, \ @@ -17,6 +19,7 @@ HEADERS = { 'X-Yandex-Music-Client': 'WindowsPhone/3.20', } +reserved_names = [name.lower() for name in dir(builtins)] + ['client'] logging.getLogger('urllib3').setLevel(logging.WARNING) @@ -63,7 +66,8 @@ class Request: cleaned_object = {} for key, value in obj.items(): key = Request._convert_camel_to_snake(key.replace('-', '_')) - key = key.replace('client', 'client_') + if key in reserved_names: + key += '_' if len(key) and key[0].isdigit(): key = '_' + key