Skip to content

Commit

Permalink
Удалён кринж 2019 года; добавлен кринж 2024 года
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshalX committed Sep 20, 2024
1 parent 98cf497 commit e56f676
Show file tree
Hide file tree
Showing 127 changed files with 584 additions and 2,298 deletions.
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# -- Project information -----------------------------------------------------

project = 'Yandex Music API'
copyright = '2019-2023 Ilya (Marshal) <https://github.com/MarshalX>'
copyright = '2019-2024 Ilya (Marshal) <https://github.com/MarshalX>'
author = 'Ilya (Marshal)'

language = 'en'
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
requests
aiohttp
aiofiles
typing-extensions
# rly dev
ruff==0.1.6
coverage
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def run_tests(self) -> None:
long_description=readme,
long_description_content_type='text/markdown',
packages=find_packages(),
install_requires=['requests[socks]', 'aiohttp', 'aiofiles'],
install_requires=['requests[socks]', 'aiohttp', 'aiofiles', 'typing-extensions'],
include_package_data=True,
classifiers=[
'Development Status :: 5 - Production/Stable',
Expand Down
6 changes: 4 additions & 2 deletions yandex_music/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
__version__ = '2.2.0'
__license__ = 'GNU Lesser General Public License v3 (LGPLv3)'
__copyright__ = 'Copyright (C) 2019-2023 Ilya (Marshal) <https://github.com/MarshalX>'
__copyright__ = 'Copyright (C) 2019-2024 Ilya (Marshal) <https://github.com/MarshalX>'

from .base import YandexMusicObject
from .base import YandexMusicObject, YandexMusicModel, JSONType

from .settings import Settings
from .permission_alerts import PermissionAlerts
Expand Down Expand Up @@ -148,6 +148,8 @@
'__license__',
'__version__',
'YandexMusicObject',
'YandexMusicModel',
'JSONType',
'Client',
'ClientAsync',
'Account',
Expand Down
10 changes: 5 additions & 5 deletions yandex_music/account/account.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from typing import TYPE_CHECKING, List, Optional

from yandex_music import YandexMusicObject
from yandex_music import JSONType, YandexMusicModel
from yandex_music.utils import model

if TYPE_CHECKING:
from yandex_music import Client, PassportPhone


@model
class Account(YandexMusicObject):
class Account(YandexMusicModel):
"""Класс, представляющий основную информацию об аккаунте пользователя.
Attributes:
Expand Down Expand Up @@ -54,7 +54,7 @@ def __post_init__(self) -> None:
self._id_attrs = (self.uid,)

@classmethod
def de_json(cls, data: dict, client: 'Client') -> Optional['Account']:
def de_json(cls, data: JSONType, client: 'Client') -> Optional['Account']:
"""Десериализация объекта.
Args:
Expand All @@ -64,10 +64,10 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Account']:
Returns:
:obj:`yandex_music.Account`: Основная информация об аккаунте пользователя.
"""
if not cls.is_valid_model_data(data):
if not cls.is_dict_model_data(data):
return None

data = super(Account, cls).de_json(data, client)
data = cls.cleanup_data(data, client)
from yandex_music import PassportPhone

data['passport_phones'] = PassportPhone.de_list(data.get('passport_phones'), client)
Expand Down
10 changes: 5 additions & 5 deletions yandex_music/account/alert.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from typing import TYPE_CHECKING, Optional

from yandex_music import YandexMusicObject
from yandex_music import JSONType, YandexMusicModel
from yandex_music.utils import model

if TYPE_CHECKING:
from yandex_music import AlertButton, Client


@model
class Alert(YandexMusicObject):
class Alert(YandexMusicModel):
"""Класс, представляющий блок с предупреждением.
Note:
Expand Down Expand Up @@ -41,7 +41,7 @@ def __post_init__(self) -> None:
self._id_attrs = (self.alert_id,)

@classmethod
def de_json(cls, data: dict, client: 'Client') -> Optional['Alert']:
def de_json(cls, data: JSONType, client: 'Client') -> Optional['Alert']:
"""Десериализация объекта.
Args:
Expand All @@ -51,12 +51,12 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Alert']:
Returns:
:obj:`yandex_music.Alert`: Сообщение о статусе подписки.
"""
if not cls.is_valid_model_data(data):
if not cls.is_dict_model_data(data):
return None

from yandex_music import AlertButton

data = super(Alert, cls).de_json(data, client)
data = cls.cleanup_data(data, client)
data['button'] = AlertButton.de_json(data.get('button'), client)

return cls(client=client, **data)
22 changes: 2 additions & 20 deletions yandex_music/account/alert_button.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from typing import TYPE_CHECKING, Optional

from yandex_music import YandexMusicObject
from yandex_music import YandexMusicModel
from yandex_music.utils import model

if TYPE_CHECKING:
from yandex_music import Client


@model
class AlertButton(YandexMusicObject):
class AlertButton(YandexMusicModel):
"""Класс, представляющий кнопку в предупреждении.
Attributes:
Expand All @@ -27,21 +27,3 @@ class AlertButton(YandexMusicObject):

def __post_init__(self) -> None:
self._id_attrs = (self.text, self.uri)

@classmethod
def de_json(cls, data: dict, client: 'Client') -> Optional['AlertButton']:
"""Десериализация объекта.
Args:
data (:obj:`dict`): Поля и значения десериализуемого объекта.
client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.
Returns:
:obj:`yandex_music.AlertButton`: Кнопка в статусе о подписки.
"""
if not cls.is_valid_model_data(data):
return None

data = super(AlertButton, cls).de_json(data, client)

return cls(client=client, **data)
28 changes: 6 additions & 22 deletions yandex_music/account/auto_renewable.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from typing import TYPE_CHECKING, List, Optional
from typing import TYPE_CHECKING, Optional

from yandex_music import YandexMusicObject
from yandex_music import JSONType, YandexMusicModel
from yandex_music.utils import model

if TYPE_CHECKING:
from yandex_music import Client, Product, User


@model
class AutoRenewable(YandexMusicObject):
class AutoRenewable(YandexMusicModel):
"""Класс, представляющий информацию об автопродлении подписки.
Attributes:
Expand Down Expand Up @@ -37,7 +37,7 @@ def __post_init__(self) -> None:
self._id_attrs = (self.expires, self.vendor, self.vendor_help_url, self.product, self.finished)

@classmethod
def de_json(cls, data: dict, client: 'Client') -> Optional['AutoRenewable']:
def de_json(cls, data: JSONType, client: 'Client') -> Optional['AutoRenewable']:
"""Десериализация объекта.
Args:
Expand All @@ -47,29 +47,13 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['AutoRenewable']:
Returns:
:obj:`yandex_music.AutoRenewable`: Информация об автопродлении подписки.
"""
if not cls.is_valid_model_data(data):
if not cls.is_dict_model_data(data):
return None

data = super(AutoRenewable, cls).de_json(data, client)
data = cls.cleanup_data(data, client)
from yandex_music import Product, User

data['product'] = Product.de_json(data.get('product'), client)
data['master_info'] = User.de_json(data.get('master_info'), client)

return cls(client=client, **data)

@classmethod
def de_list(cls, data: list, client: 'Client') -> List['AutoRenewable']:
"""Десериализация списка объектов.
Args:
data (:obj:`list`): Список словарей с полями и значениями десериализуемого объекта.
client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.
Returns:
:obj:`list` из :obj:`yandex_music.AutoRenewable`: Информация об автопродлении подписки.
"""
if not cls.is_valid_model_data(data, array=True):
return []

return [cls.de_json(auto_renewable, client) for auto_renewable in data]
40 changes: 3 additions & 37 deletions yandex_music/account/deactivation.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from typing import TYPE_CHECKING, List, Optional
from typing import TYPE_CHECKING, Optional

from yandex_music import YandexMusicObject
from yandex_music import YandexMusicModel
from yandex_music.utils import model

if TYPE_CHECKING:
from yandex_music import Client


@model
class Deactivation(YandexMusicObject):
class Deactivation(YandexMusicModel):
"""Класс, представляющий способы деактивации мобильной услуги.
Note:
Expand All @@ -26,37 +26,3 @@ class Deactivation(YandexMusicObject):

def __post_init__(self) -> None:
self._id_attrs = (self.method, self.instructions)

@classmethod
def de_json(cls, data: dict, client: 'Client') -> Optional['Deactivation']:
"""Десериализация объекта.
Args:
data (:obj:`dict`): Поля и значения десериализуемого объекта.
client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.
Returns:
:obj:`yandex_music.Deactivation`: Способ отключения услуги.
"""
if not cls.is_valid_model_data(data):
return None

data = super(Deactivation, cls).de_json(data, client)

return cls(client=client, **data)

@classmethod
def de_list(cls, data: list, client: 'Client') -> List['Deactivation']:
"""Десериализация списка объектов.
Args:
data (:obj:`list`): Список словарей с полями и значениями десериализуемого объекта.
client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.
Returns:
:obj:`list` из :obj:`yandex_music.Deactivation`: Способы отключения услуги.
"""
if not cls.is_valid_model_data(data, array=True):
return []

return [cls.de_json(deactivation, client) for deactivation in data]
22 changes: 2 additions & 20 deletions yandex_music/account/non_auto_renewable.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from typing import TYPE_CHECKING, Optional

from yandex_music import YandexMusicObject
from yandex_music import YandexMusicModel
from yandex_music.utils import model

if TYPE_CHECKING:
from yandex_music import Client


@model
class NonAutoRenewable(YandexMusicObject):
class NonAutoRenewable(YandexMusicModel):
"""Класс, представляющий отключённое автопродление.
Attributes:
Expand All @@ -23,21 +23,3 @@ class NonAutoRenewable(YandexMusicObject):

def __post_init__(self) -> None:
self._id_attrs = (self.start, self.end)

@classmethod
def de_json(cls, data: dict, client: 'Client') -> Optional['NonAutoRenewable']:
"""Десериализация объекта.
Args:
data (:obj:`dict`): Поля и значения десериализуемого объекта.
client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.
Returns:
:obj:`yandex_music.NonAutoRenewable`: Отключённое автопродление.
"""
if not cls.is_valid_model_data(data):
return None

data = super(NonAutoRenewable, cls).de_json(data, client)

return cls(client=client, **data)
28 changes: 5 additions & 23 deletions yandex_music/account/operator.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from typing import TYPE_CHECKING, List, Optional

from yandex_music import YandexMusicObject
from yandex_music import JSONType, YandexMusicModel
from yandex_music.utils import model

if TYPE_CHECKING:
from yandex_music import Client, Deactivation


@model
class Operator(YandexMusicObject):
class Operator(YandexMusicModel):
"""Класс, представляющий услугу сотового оператора.
Attributes:
Expand All @@ -33,7 +33,7 @@ def __post_init__(self) -> None:
self._id_attrs = (self.product_id, self.phone)

@classmethod
def de_json(cls, data: dict, client: 'Client') -> Optional['Operator']:
def de_json(cls, data: JSONType, client: 'Client') -> Optional['Operator']:
"""Десериализация объекта.
Args:
Expand All @@ -43,29 +43,11 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Operator']:
Returns:
:obj:`yandex_music.Operator`: Услуга сотового оператора.
"""
if not cls.is_valid_model_data(data):
if not cls.is_dict_model_data(data):
return None

from yandex_music import Deactivation

data['deactivation'] = Deactivation.de_list(data.get('deactivation'), client)

data = super(Operator, cls).de_json(data, client)

return cls(client=client, **data)

@classmethod
def de_list(cls, data: list, client: 'Client') -> List['Operator']:
"""Десериализация списка объектов.
Args:
data (:obj:`list`): Список словарей с полями и значениями десериализуемого объекта.
client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.
Returns:
:obj:`list` из :obj:`yandex_music.Operator`: Услуги сотового оператора.
"""
if not cls.is_valid_model_data(data, array=True):
return []

return [cls.de_json(operator, client) for operator in data]
return cls(client=client, **cls.cleanup_data(data, client))
Loading

0 comments on commit e56f676

Please sign in to comment.