Archived
music_api/compat.py 是「同步调用异步实现」的桥接门面——每个方法都用 core.async_bridge.run_sync 把 NeteaseAPI 的协程跑起来。调用方此前已陆续 迁到原生异步(await NeteaseAPI().xxx()),这 16 个方法在仓内(web/ services/ tests/ CLI)已零调用,只剩 __init__ 的再导出,属迁移期残留。 仅 url_v1 还有唯一调用方(music_api.podcast 的同步解析路径),予以保留, 并在 docstring 标注「应删不应增」,待 worker 子系统异步化时一并清除。 门禁:ruff 全过 / pyright 0-0 / pytest 387 项,失败数与前次一致(2 项 index golden,源于未提交的前端迁移,与本次无关)。
66 lines
1.3 KiB
Python
66 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""网易云音乐API模块
|
|
|
|
提供网易云音乐相关API接口的封装,包括:
|
|
- 音乐URL获取
|
|
- 歌曲详情获取
|
|
- 歌词获取
|
|
- 搜索功能
|
|
- 歌单和专辑详情
|
|
- 二维码登录
|
|
"""
|
|
|
|
# 兼容门面:实现已按职责拆分到同包各子模块,此处原样再导出。
|
|
# 用 `__all__` 声明再导出(ruff F401 与 pyright 均据此认定「有意再导出」),
|
|
# 使既有调用点(music_api.xxx / from music_api import Y)零改动。
|
|
|
|
from .api import (
|
|
NeteaseAPI,
|
|
)
|
|
from .client import (
|
|
_MAX_UPSTREAM_JSON_BYTES,
|
|
HTTPClient,
|
|
_as_dict,
|
|
_ensure_dict,
|
|
)
|
|
from .compat import (
|
|
url_v1,
|
|
)
|
|
from .constants import (
|
|
APIConstants,
|
|
QualityLevel,
|
|
)
|
|
from .cookies import (
|
|
DEFAULT_COOKIE_FILE,
|
|
load_cookies,
|
|
parse_cookie_string,
|
|
)
|
|
from .crypto import (
|
|
CryptoUtils,
|
|
WeapiCrypto,
|
|
)
|
|
from .errors import (
|
|
APIException,
|
|
)
|
|
from .qr import (
|
|
QRLoginManager,
|
|
)
|
|
|
|
__all__ = [
|
|
'DEFAULT_COOKIE_FILE',
|
|
'_MAX_UPSTREAM_JSON_BYTES',
|
|
'APIConstants',
|
|
'APIException',
|
|
'CryptoUtils',
|
|
'HTTPClient',
|
|
'NeteaseAPI',
|
|
'QRLoginManager',
|
|
'QualityLevel',
|
|
'WeapiCrypto',
|
|
'_as_dict',
|
|
'_ensure_dict',
|
|
'load_cookies',
|
|
'parse_cookie_string',
|
|
'url_v1',
|
|
]
|