diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index f17d381..f5a5f01 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -21,5 +21,8 @@ jobs: path: .cache restore-keys: | mkdocs-material- - - run: pip install mkdocs-material pygments mkdocstrings - - run: mkdocs gh-deploy --force + - uses: abatilo/actions-poetry@v2 + with: + poetry-version: 1.6.1 + - run: poetry install --only docs + - run: poetry run mkdocs gh-deploy --force diff --git a/docs/api.md b/docs/api.md deleted file mode 100644 index 0199ddf..0000000 --- a/docs/api.md +++ /dev/null @@ -1,30 +0,0 @@ -# 使用示例 - -## 歌曲接口 - -### 查询歌曲信息 - -=== "mid" - ```py - api.song.query(mid=["003BdoNA0VyJB9","002mCZr11MN9Tj"]) - # or - api.song.query(mid="003BdoNA0VyJB9") - ``` -=== "id" - ```py - api.song.query(id=[398352513,384143504]) - # or - api.song.query(id=398352513) - ``` - -### 获取歌曲详细信息 -```py -# 仅支持mid -api.song.detail("003BdoNA0VyJB9") -``` - -### 获取歌曲文件链接 -```py -# 仅支持mid -api.song.url("003BdoNA0VyJB9") -``` diff --git a/mkdocs.yml b/mkdocs.yml index 58c0152..446e623 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -21,17 +21,27 @@ theme: toggle: icon: material/brightness-4 name: Switch to system preference + icon: + repo: fontawesome/brands/github features: - search.suggest - search.highlight - content.tabs.link - navigation.indexes - content.tooltips + - navigation.top - navigation.path + - navigation.instant + - navigation.instant.prefetch + - navigation.instant.progress + - navigation.tracking - content.code.annotate - content.code.copy - content.code.select +repo_name: luren-dc/QQMusicApi +repo_url: https://github.com/luren-dc/QQMusicApi + markdown_extensions: # Python Markdown - abbr @@ -69,4 +79,17 @@ markdown_extensions: plugins: - search - - mkdocstrings + - mkdocstrings: + handlers: + python: + setup_commands: + - import sys + - sys.path.insert(0, ".") + import: + # latest instead of stable + - https://installer.readthedocs.io/en/latest/objects.inv + - https://docs.python.org/3/objects.inv + - autorefs + - git-revision-date-localized: + enable_creation_date: true + - git-authors diff --git a/poetry.lock b/poetry.lock index 2072b6f..4d43510 100644 --- a/poetry.lock +++ b/poetry.lock @@ -513,6 +513,51 @@ python-dateutil = ">=2.8.1" [package.extras] dev = ["flake8", "markdown", "twine", "wheel"] +[[package]] +name = "gitdb" +version = "4.0.10" +description = "Git Object Database" +optional = false +python-versions = ">=3.7" +files = [ + {file = "gitdb-4.0.10-py3-none-any.whl", hash = "sha256:c286cf298426064079ed96a9e4a9d39e7f3e9bf15ba60701e95f5492f28415c7"}, + {file = "gitdb-4.0.10.tar.gz", hash = "sha256:6eb990b69df4e15bad899ea868dc46572c3f75339735663b81de79b06f17eb9a"}, +] + +[package.dependencies] +smmap = ">=3.0.1,<6" + +[[package]] +name = "gitpython" +version = "3.1.37" +description = "GitPython is a Python library used to interact with Git repositories" +optional = false +python-versions = ">=3.7" +files = [ + {file = "GitPython-3.1.37-py3-none-any.whl", hash = "sha256:5f4c4187de49616d710a77e98ddf17b4782060a1788df441846bddefbb89ab33"}, + {file = "GitPython-3.1.37.tar.gz", hash = "sha256:f9b9ddc0761c125d5780eab2d64be4873fc6817c2899cbcb34b02344bdc7bc54"}, +] + +[package.dependencies] +gitdb = ">=4.0.1,<5" + +[package.extras] +test = ["black", "coverage[toml]", "ddt (>=1.1.1,!=1.4.3)", "mypy", "pre-commit", "pytest", "pytest-cov", "pytest-sugar"] + +[[package]] +name = "griffe" +version = "0.36.5" +description = "Signatures for entire Python programs. Extract the structure, the frame, the skeleton of your project, to generate API documentation or find breaking changes in your API." +optional = false +python-versions = ">=3.8" +files = [ + {file = "griffe-0.36.5-py3-none-any.whl", hash = "sha256:62af1ca94a5ac73259278b7692d300bf1c6bd8f9beeabaeaa229009bb82d09c6"}, + {file = "griffe-0.36.5.tar.gz", hash = "sha256:b8a672c54b99e958b985b3cfbf1de09e25d686dd8a667aa5ec2d0b1601a542fc"}, +] + +[package.dependencies] +colorama = ">=0.4" + [[package]] name = "idna" version = "3.4" @@ -705,6 +750,37 @@ files = [ Markdown = ">=3.3" mkdocs = ">=1.1" +[[package]] +name = "mkdocs-git-authors-plugin" +version = "0.7.2" +description = "Mkdocs plugin to display git authors of a page" +optional = false +python-versions = ">=3.7" +files = [ + {file = "mkdocs-git-authors-plugin-0.7.2.tar.gz", hash = "sha256:f541730e4cabdafa0ac758c94d28ba5e8ddca4c859e5de4c89f1226cb6ccd0ad"}, + {file = "mkdocs_git_authors_plugin-0.7.2-py3-none-any.whl", hash = "sha256:c8a2784a867db79ad3b477a96ee96875d17b09192b6d3be71f08df25afff76c4"}, +] + +[package.dependencies] +mkdocs = ">=1.0" + +[[package]] +name = "mkdocs-git-revision-date-localized-plugin" +version = "1.2.0" +description = "Mkdocs plugin that enables displaying the localized date of the last git modification of a markdown file." +optional = false +python-versions = ">=3.6" +files = [ + {file = "mkdocs-git-revision-date-localized-plugin-1.2.0.tar.gz", hash = "sha256:7752edd7c4dcaa9383e9a5b6a4f729831a62d604b0c43b319331127720c6a2bf"}, + {file = "mkdocs_git_revision_date_localized_plugin-1.2.0-py3-none-any.whl", hash = "sha256:540b9c930d8d48630c090b72ac2c3900ac2ed0799b23738a33b88e31f5198fe7"}, +] + +[package.dependencies] +babel = ">=2.7.0" +GitPython = "*" +mkdocs = ">=1.0" +pytz = "*" + [[package]] name = "mkdocs-material" version = "9.4.5" @@ -763,6 +839,7 @@ Markdown = ">=3.3" MarkupSafe = ">=1.1" mkdocs = ">=1.2" mkdocs-autorefs = ">=0.3.1" +mkdocstrings-python = {version = ">=0.5.2", optional = true, markers = "extra == \"python\""} pymdown-extensions = ">=6.3" typing-extensions = {version = ">=4.1", markers = "python_version < \"3.10\""} @@ -771,6 +848,21 @@ crystal = ["mkdocstrings-crystal (>=0.3.4)"] python = ["mkdocstrings-python (>=0.5.2)"] python-legacy = ["mkdocstrings-python-legacy (>=0.2.1)"] +[[package]] +name = "mkdocstrings-python" +version = "1.7.3" +description = "A Python handler for mkdocstrings." +optional = false +python-versions = ">=3.8" +files = [ + {file = "mkdocstrings_python-1.7.3-py3-none-any.whl", hash = "sha256:2439d6ad3e34f0bb4c643b845fb3c06ae9233499a1736f9fa273424b75cc5894"}, + {file = "mkdocstrings_python-1.7.3.tar.gz", hash = "sha256:c20128fa96c24dbc6437b10dfedaf33b0415d4503e51ce9ce5e84b271278268e"}, +] + +[package.dependencies] +griffe = ">=0.35" +mkdocstrings = ">=0.20" + [[package]] name = "multidict" version = "6.0.4" @@ -1333,6 +1425,17 @@ files = [ {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, ] +[[package]] +name = "smmap" +version = "5.0.1" +description = "A pure Python implementation of a sliding window memory map manager" +optional = false +python-versions = ">=3.7" +files = [ + {file = "smmap-5.0.1-py3-none-any.whl", hash = "sha256:e6d8668fa5f93e706934a62d7b4db19c8d9eb8cf2adbb75ef1b675aa332b69da"}, + {file = "smmap-5.0.1.tar.gz", hash = "sha256:dceeb6c0028fdb6734471eb07c0cd2aae706ccaecab45965ee83f11c8d3b1f62"}, +] + [[package]] name = "tomli" version = "2.0.1" @@ -1516,4 +1619,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "c45753820d5d360db955e7c24b89b8950ef7dde82072747bc029960ce0be0ad5" +content-hash = "2b39133c18755dba4c5b75c163a4dd5a565ef3ff742217dbd4ab25e14d3c87da" diff --git a/pyproject.toml b/pyproject.toml index efe9fde..64852dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,8 +15,11 @@ aiohttp = "^3.8.5" [tool.poetry.group.docs.dependencies] mkdocs-material = "^9.4.4" mkdocs = "^1.5.3" -mkdocstrings = "^0.23.0" +mkdocstrings = {extras = ["python"], version = "^0.23.0"} pygments = "^2.16.1" +mkdocs-autorefs = "^0.5.0" +mkdocs-git-authors-plugin = "^0.7.2" +mkdocs-git-revision-date-localized-plugin = "^1.2.0" [tool.poetry.group.dev.dependencies] pytest = "^7.4.0" diff --git a/qqmusicapi/api/README.md b/qqmusicapi/api/README.md deleted file mode 100644 index 2b2b7d4..0000000 --- a/qqmusicapi/api/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# Api说明 - -## SongApi - -### 标识码类别 - -| 标识码 | 后缀名 | 音质 | 特殊说明 | -| ------ | ------ | ---------- | -------------- | -| AI00 | .flac | 192000 Hz | Premium-Master | -| Q001 | .flac | - | Premium-Atmos-2 | -| Q000 | .flac | 44100 Hz | Premium-Atmos-51 | -| V000 | .flac | - | - | -| RS01 | .flac | - | - | -| A000 | .flac | - | - | -| F000 | .flac | 44100 Hz | - | -| M800 | .mp3 | 320000 bps | - | -| D004 | .m4a | - | - | -| O800 | .ogg | 320000 bps | - | -| C600 | .m4a | 191816 bps | - | -| O600 | .ogg | 192000 bps | - | -| M500 | .mp3 | 128000 bps | - | -| C400 | .m4a | 96656 bps | - | -| O400 | .ogg | 48248 bps | - | -| C200 | .m4a | 48248 bps | - | -| C100 | .m4a | - | - | - -### 标识码说明 - -> 第一位:表示音频类型。\ -> 第二位:表示音频音质。\ -> 第三位:表示音频加密。\ -> "M"为加密,"0"为未加密\ -> 第四位:未知。 diff --git a/qqmusicapi/api/login.py b/qqmusicapi/api/login.py index 403dedd..d6e1b01 100644 --- a/qqmusicapi/api/login.py +++ b/qqmusicapi/api/login.py @@ -84,7 +84,7 @@ async def authorize(self, code: Optional[int] = None) -> bool: 验证。 Args: - code: 验证码 + code: 验证码。仅在使用手机号登录时传递。 Returns: bool: 是否登录成功 @@ -425,7 +425,7 @@ def request(login_type: int = 0, phone: Optional[int] = None) -> Login: 创建登录对象。 Args: - login_type : 登录类型。0 表示 QQ 登录,1 表示微信登录,2 表示手机号登录。默认为 0。 + login_type : 登录类型。0=QQ 登录,1=微信登录,2=手机号登录。 phone: 手机号(可选)。 Returns: diff --git a/qqmusicapi/api/song.py b/qqmusicapi/api/song.py index a54c464..d3d17bc 100644 --- a/qqmusicapi/api/song.py +++ b/qqmusicapi/api/song.py @@ -12,17 +12,12 @@ class SongApi: - """歌曲Api""" + """歌曲API""" parent: ClassVar[QQMusic] """ - 文件类型与其对应的前缀和后缀 - 试听 需要拼接歌曲信息中的vs - "audition": { - "s": "RS02", - "e": ".mp3", - } + 文件类 """ FILE_TYPE = { "AI00": ".flac", @@ -42,6 +37,7 @@ class SongApi: "O400": ".ogg", "C200": ".m4a", "C100": ".m4a", + "RS02": ".mp3", } @staticmethod diff --git a/tests/test_login.py b/tests/test_login.py index fb2cecf..3c18cfe 100644 --- a/tests/test_login.py +++ b/tests/test_login.py @@ -38,7 +38,8 @@ async def login(type: int): elif state == 0: break await asyncio.sleep(1) - return await login.authorize() + await login.authorize() + print(login.token) @pytest.mark.asyncio