@sansenjian/qq-music-api 2.2.1 → 2.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +124 -33
- package/README.md +2 -0
- package/dist/app.js +77 -0
- package/dist/config/service-config.js +37 -0
- package/dist/config/user-info.js +59 -0
- package/dist/index.js +3 -0
- package/dist/jest.config.js +52 -0
- package/dist/middlewares/fallback-middleware.js +29 -0
- package/dist/middlewares/koa-cors.js +63 -0
- package/dist/module/apis/UCommon/UCommon.js +10 -0
- package/dist/module/apis/album/getAlbumInfo.js +23 -0
- package/dist/module/apis/comments/getComments.js +24 -0
- package/dist/module/apis/digitalAlbum/getDigitalAlbumLists.js +22 -0
- package/dist/module/apis/downloadQQMusic.js +48 -0
- package/dist/module/apis/extend/getPlaylistTags.js +158 -0
- package/dist/module/apis/music/getLyric.js +32 -0
- package/dist/module/apis/music/getMusicPlay.js +187 -0
- package/dist/module/apis/mv/getMvByTag.js +23 -0
- package/dist/module/apis/radio/getRadioLists.js +26 -0
- package/dist/module/apis/rank/getTopLists.js +35 -0
- package/dist/module/apis/recommend/getDailyRecommend.js +124 -0
- package/dist/module/apis/recommend/getPersonalRecommend.js +114 -0
- package/dist/module/apis/search/getHotKey.js +25 -0
- package/dist/module/apis/search/getSearchByKey.js +32 -0
- package/dist/module/apis/search/getSmartbox.js +40 -0
- package/dist/module/apis/singers/getSimilarSinger.js +24 -0
- package/dist/module/apis/singers/getSingerDesc.js +24 -0
- package/dist/module/apis/singers/getSingerMv.js +23 -0
- package/dist/module/apis/singers/getSingerStarNum.js +23 -0
- package/dist/module/apis/songLists/songListCategories.js +23 -0
- package/dist/module/apis/songLists/songListDetail.js +28 -0
- package/dist/module/apis/songLists/songLists.js +35 -0
- package/dist/module/apis/u_common.js +62 -0
- package/dist/module/apis/user/checkQQLoginQr.js +189 -0
- package/dist/module/apis/user/getQQLoginQr.js +23 -0
- package/dist/module/apis/user/getUserAvatar.js +25 -0
- package/dist/module/apis/user/getUserLikedSongs.js +129 -0
- package/dist/module/apis/user/getUserPlaylists.js +138 -0
- package/dist/module/apis/y_common.js +69 -0
- package/dist/module/config.js +24 -0
- package/dist/module/index.js +72 -0
- package/dist/package.json +120 -0
- package/dist/routers/context/batchGetSongInfo.js +48 -0
- package/dist/routers/context/batchGetSongLists.js +35 -0
- package/dist/routers/context/checkQQLoginQr.js +16 -0
- package/dist/routers/context/cookies.js +36 -0
- package/dist/routers/context/getAlbumInfo.js +22 -0
- package/dist/routers/context/getComments.js +31 -0
- package/dist/routers/context/getDailyRecommend.js +33 -0
- package/dist/routers/context/getDigitalAlbumLists.js +16 -0
- package/dist/routers/context/getDownloadQQMusic.js +16 -0
- package/dist/routers/context/getHotkey.js +20 -0
- package/dist/routers/context/getImageUrl.js +25 -0
- package/dist/routers/context/getLyric.js +29 -0
- package/dist/routers/context/getMusicPlay.js +33 -0
- package/dist/routers/context/getMv.js +51 -0
- package/dist/routers/context/getMvByTag.js +16 -0
- package/dist/routers/context/getMvPlay.js +104 -0
- package/dist/routers/context/getNewDisks.js +52 -0
- package/dist/routers/context/getPersonalRecommend.js +42 -0
- package/dist/routers/context/getPlaylistTags.js +54 -0
- package/dist/routers/context/getQQLoginQr.js +14 -0
- package/dist/routers/context/getRadioLists.js +16 -0
- package/dist/routers/context/getRanks.js +53 -0
- package/dist/routers/context/getRecommend.js +88 -0
- package/dist/routers/context/getSearchByKey.js +32 -0
- package/dist/routers/context/getSimilarSinger.js +27 -0
- package/dist/routers/context/getSingerAlbum.js +48 -0
- package/dist/routers/context/getSingerDesc.js +28 -0
- package/dist/routers/context/getSingerHotsong.js +48 -0
- package/dist/routers/context/getSingerList.js +39 -0
- package/dist/routers/context/getSingerMv.js +36 -0
- package/dist/routers/context/getSingerStarNum.js +27 -0
- package/dist/routers/context/getSmartbox.js +27 -0
- package/dist/routers/context/getSongInfo.js +40 -0
- package/dist/routers/context/getSongListCategories.js +22 -0
- package/dist/routers/context/getSongListDetail.js +17 -0
- package/dist/routers/context/getSongLists.js +25 -0
- package/dist/routers/context/getTicketInfo.js +47 -0
- package/dist/routers/context/getTopLists.js +16 -0
- package/dist/routers/context/getUserAvatar.js +35 -0
- package/dist/routers/context/getUserLikedSongs.js +24 -0
- package/dist/routers/context/getUserPlaylists.js +27 -0
- package/dist/routers/context/index.js +98 -0
- package/dist/routers/router.js +69 -0
- package/dist/routers/types.js +2 -0
- package/dist/routers/util.js +219 -0
- package/dist/scripts/run-tests-with-flags.js +139 -0
- package/dist/types/api.js +55 -0
- package/dist/util/apiResponse.js +88 -0
- package/dist/util/colors.js +19 -0
- package/dist/util/cookie.js +34 -0
- package/dist/util/cookieResolver.js +66 -0
- package/dist/util/loginUtils.js +30 -0
- package/dist/util/lyricParse.js +72 -0
- package/dist/util/request.js +118 -0
- package/docs-dist/404.html +24 -0
- package/docs-dist/CHANGELOG-ARCHITECTURE.html +131 -0
- package/docs-dist/COOKIE_CONFIG_GUIDE.html +39 -0
- package/docs-dist/FALLBACK_MODE_GUIDE.html +101 -0
- package/docs-dist/README.html +447 -0
- package/docs-dist/TEST_USER_PLAYLISTS.html +42 -0
- package/docs-dist/USER_AVATAR_GUIDE.html +100 -0
- package/docs-dist/api/comments.html +48 -0
- package/docs-dist/api/index.html +27 -0
- package/docs-dist/api/music.html +51 -0
- package/docs-dist/api/other.html +33 -0
- package/docs-dist/api/playlist.html +77 -0
- package/docs-dist/api/rank.html +48 -0
- package/docs-dist/api/search.html +62 -0
- package/docs-dist/api/singer.html +47 -0
- package/docs-dist/api/user.html +64 -0
- package/docs-dist/assets/CHANGELOG-ARCHITECTURE.md.r40JGJZK.js +105 -0
- package/docs-dist/assets/CHANGELOG-ARCHITECTURE.md.r40JGJZK.lean.js +1 -0
- package/docs-dist/assets/COOKIE_CONFIG_GUIDE.md.BVXl7WHu.js +13 -0
- package/docs-dist/assets/COOKIE_CONFIG_GUIDE.md.BVXl7WHu.lean.js +1 -0
- package/docs-dist/assets/FALLBACK_MODE_GUIDE.md.BBdcIdh_.js +75 -0
- package/docs-dist/assets/FALLBACK_MODE_GUIDE.md.BBdcIdh_.lean.js +1 -0
- package/docs-dist/assets/README.md.D6Tw0nRd.js +421 -0
- package/docs-dist/assets/README.md.D6Tw0nRd.lean.js +1 -0
- package/docs-dist/assets/TEST_USER_PLAYLISTS.md.DSt20Igj.js +16 -0
- package/docs-dist/assets/TEST_USER_PLAYLISTS.md.DSt20Igj.lean.js +1 -0
- package/docs-dist/assets/USER_AVATAR_GUIDE.md.CVHPs2Dn.js +74 -0
- package/docs-dist/assets/USER_AVATAR_GUIDE.md.CVHPs2Dn.lean.js +1 -0
- package/docs-dist/assets/api_comments.md.79Q_C8Qp.js +22 -0
- package/docs-dist/assets/api_comments.md.79Q_C8Qp.lean.js +1 -0
- package/docs-dist/assets/api_index.md.CU3By8tw.js +1 -0
- package/docs-dist/assets/api_index.md.CU3By8tw.lean.js +1 -0
- package/docs-dist/assets/api_music.md.B1AzLePX.js +25 -0
- package/docs-dist/assets/api_music.md.B1AzLePX.lean.js +1 -0
- package/docs-dist/assets/api_other.md.DCg4bzA7.js +7 -0
- package/docs-dist/assets/api_other.md.DCg4bzA7.lean.js +1 -0
- package/docs-dist/assets/api_playlist.md.8ACJ3QqD.js +51 -0
- package/docs-dist/assets/api_playlist.md.8ACJ3QqD.lean.js +1 -0
- package/docs-dist/assets/api_rank.md.B8IP2ZRy.js +22 -0
- package/docs-dist/assets/api_rank.md.B8IP2ZRy.lean.js +1 -0
- package/docs-dist/assets/api_search.md.DO9J6nvp.js +36 -0
- package/docs-dist/assets/api_search.md.DO9J6nvp.lean.js +1 -0
- package/docs-dist/assets/api_singer.md.CcL32xuN.js +21 -0
- package/docs-dist/assets/api_singer.md.CcL32xuN.lean.js +1 -0
- package/docs-dist/assets/api_user.md.Cb7Ky3Sn.js +38 -0
- package/docs-dist/assets/api_user.md.Cb7Ky3Sn.lean.js +1 -0
- package/docs-dist/assets/app.CSainqD9.js +1 -0
- package/docs-dist/assets/chunks/@localSearchIndexroot.BKleDIv-.js +1 -0
- package/docs-dist/assets/chunks/VPLocalSearchBox.BUBaq7tw.js +9 -0
- package/docs-dist/assets/chunks/framework.aJbMEiY9.js +19 -0
- package/docs-dist/assets/chunks/theme.CzMhU0Ps.js +2 -0
- package/docs-dist/assets/guide_architecture.md.CzgqynmB.js +258 -0
- package/docs-dist/assets/guide_architecture.md.CzgqynmB.lean.js +1 -0
- package/docs-dist/assets/guide_authentication.md.a8yTA8Xe.js +4 -0
- package/docs-dist/assets/guide_authentication.md.a8yTA8Xe.lean.js +1 -0
- package/docs-dist/assets/guide_index.md.BgUUL6fI.js +1 -0
- package/docs-dist/assets/guide_index.md.BgUUL6fI.lean.js +1 -0
- package/docs-dist/assets/guide_installation.md.BCZ4jBl_.js +7 -0
- package/docs-dist/assets/guide_installation.md.BCZ4jBl_.lean.js +1 -0
- package/docs-dist/assets/guide_quickstart.md.9-4dA6wS.js +13 -0
- package/docs-dist/assets/guide_quickstart.md.9-4dA6wS.lean.js +1 -0
- package/docs-dist/assets/index.md.z0hAJioN.js +1 -0
- package/docs-dist/assets/index.md.z0hAJioN.lean.js +1 -0
- package/docs-dist/assets/inter-italic-cyrillic-ext.r48I6akx.woff2 +0 -0
- package/docs-dist/assets/inter-italic-cyrillic.By2_1cv3.woff2 +0 -0
- package/docs-dist/assets/inter-italic-greek-ext.1u6EdAuj.woff2 +0 -0
- package/docs-dist/assets/inter-italic-greek.DJ8dCoTZ.woff2 +0 -0
- package/docs-dist/assets/inter-italic-latin-ext.CN1xVJS-.woff2 +0 -0
- package/docs-dist/assets/inter-italic-latin.C2AdPX0b.woff2 +0 -0
- package/docs-dist/assets/inter-italic-vietnamese.BSbpV94h.woff2 +0 -0
- package/docs-dist/assets/inter-roman-cyrillic-ext.BBPuwvHQ.woff2 +0 -0
- package/docs-dist/assets/inter-roman-cyrillic.C5lxZ8CY.woff2 +0 -0
- package/docs-dist/assets/inter-roman-greek-ext.CqjqNYQ-.woff2 +0 -0
- package/docs-dist/assets/inter-roman-greek.BBVDIX6e.woff2 +0 -0
- package/docs-dist/assets/inter-roman-latin-ext.4ZJIpNVo.woff2 +0 -0
- package/docs-dist/assets/inter-roman-latin.Di8DUHzh.woff2 +0 -0
- package/docs-dist/assets/inter-roman-vietnamese.BjW4sHH5.woff2 +0 -0
- package/docs-dist/assets/reference_response-format.md.VvQTLDZr.js +12 -0
- package/docs-dist/assets/reference_response-format.md.VvQTLDZr.lean.js +1 -0
- package/docs-dist/assets/style.DM4qKDd4.css +1 -0
- package/docs-dist/guide/architecture.html +284 -0
- package/docs-dist/guide/authentication.html +30 -0
- package/docs-dist/guide/index.html +27 -0
- package/docs-dist/guide/installation.html +33 -0
- package/docs-dist/guide/quickstart.html +39 -0
- package/docs-dist/hashmap.json +1 -0
- package/docs-dist/index.html +27 -0
- package/docs-dist/logo.svg +4 -0
- package/docs-dist/reference/response-format.html +38 -0
- package/docs-dist/version.json +7 -0
- package/docs-dist/vp-icons.css +1 -0
- package/package.json +31 -17
- package/.babelrc +0 -7
- package/.dockerignore +0 -5
- package/.editorconfig +0 -31
- package/.eslintrc.json +0 -22
- package/.github/workflows/deploy-docs.yml +0 -54
- package/.github/workflows/release.yml +0 -37
- package/.github/workflows/test.yml +0 -70
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -1
- package/.prettierignore +0 -1
- package/.prettierrc +0 -9
- package/AGENTS.md +0 -153
- package/Dockerfile +0 -18
- package/QQ/351/237/263/344/271/220-v0.xmind +0 -0
- package/QQ/351/237/263/344/271/220-v1.xmind +0 -0
- package/app.ts +0 -68
- package/commitlint.config.js +0 -20
- package/config/user-info.ts +0 -71
- package/index.ts +0 -1
- package/jest.config.ts +0 -41
- package/middlewares/koa-cors.ts +0 -81
- package/module/apis/UCommon/UCommon.ts +0 -13
- package/module/apis/album/getAlbumInfo.ts +0 -22
- package/module/apis/comments/getComments.ts +0 -23
- package/module/apis/digitalAlbum/getDigitalAlbumLists.ts +0 -23
- package/module/apis/downloadQQMusic.ts +0 -51
- package/module/apis/music/getLyric.ts +0 -34
- package/module/apis/mv/getMvByTag.ts +0 -24
- package/module/apis/radio/getRadioLists.ts +0 -27
- package/module/apis/rank/getTopLists.ts +0 -37
- package/module/apis/search/getHotKey.ts +0 -24
- package/module/apis/search/getSearchByKey.ts +0 -31
- package/module/apis/search/getSmartbox.ts +0 -43
- package/module/apis/singers/getSimilarSinger.ts +0 -25
- package/module/apis/singers/getSingerDesc.ts +0 -25
- package/module/apis/singers/getSingerMv.ts +0 -24
- package/module/apis/singers/getSingerStarNum.ts +0 -24
- package/module/apis/songLists/songListCategories.ts +0 -22
- package/module/apis/songLists/songListDetail.ts +0 -27
- package/module/apis/songLists/songLists.ts +0 -35
- package/module/apis/u_common.ts +0 -29
- package/module/apis/user/checkQQLoginQr.ts +0 -230
- package/module/apis/user/getQQLoginQr.ts +0 -28
- package/module/apis/user/getUserAvatar.ts +0 -32
- package/module/apis/user/getUserLikedSongs.ts +0 -145
- package/module/apis/user/getUserPlaylists.ts +0 -163
- package/module/apis/y_common.ts +0 -44
- package/module/config.ts +0 -24
- package/module/index.ts +0 -95
- package/music.png +0 -0
- package/pnpm-workspace.yaml +0 -2
- package/public/index.html +0 -430
- package/routers/context/batchGetSongInfo.ts +0 -60
- package/routers/context/batchGetSongLists.ts +0 -46
- package/routers/context/checkQQLoginQr.ts +0 -19
- package/routers/context/cookies.ts +0 -38
- package/routers/context/getAlbumInfo.ts +0 -31
- package/routers/context/getComments.ts +0 -51
- package/routers/context/getDigitalAlbumLists.ts +0 -18
- package/routers/context/getDownloadQQMusic.ts +0 -17
- package/routers/context/getHotkey.ts +0 -25
- package/routers/context/getImageUrl.ts +0 -29
- package/routers/context/getLyric.ts +0 -32
- package/routers/context/getMusicPlay.ts +0 -102
- package/routers/context/getMv.ts +0 -61
- package/routers/context/getMvByTag.ts +0 -18
- package/routers/context/getMvPlay.ts +0 -114
- package/routers/context/getNewDisks.ts +0 -58
- package/routers/context/getQQLoginQr.ts +0 -16
- package/routers/context/getRadioLists.ts +0 -18
- package/routers/context/getRanks.ts +0 -67
- package/routers/context/getRecommend.ts +0 -92
- package/routers/context/getSearchByKey.ts +0 -34
- package/routers/context/getSimilarSinger.ts +0 -29
- package/routers/context/getSingerAlbum.ts +0 -58
- package/routers/context/getSingerDesc.ts +0 -30
- package/routers/context/getSingerHotsong.ts +0 -58
- package/routers/context/getSingerList.ts +0 -56
- package/routers/context/getSingerMv.ts +0 -41
- package/routers/context/getSingerStarNum.ts +0 -29
- package/routers/context/getSmartbox.ts +0 -27
- package/routers/context/getSongInfo.ts +0 -51
- package/routers/context/getSongListCategories.ts +0 -23
- package/routers/context/getSongListDetail.ts +0 -22
- package/routers/context/getSongLists.ts +0 -30
- package/routers/context/getTicketInfo.ts +0 -51
- package/routers/context/getTopLists.ts +0 -18
- package/routers/context/getUserAvatar.ts +0 -53
- package/routers/context/getUserLikedSongs.ts +0 -28
- package/routers/context/getUserPlaylists.ts +0 -29
- package/routers/context/index.ts +0 -87
- package/routers/router.ts +0 -88
- package/routers/types.ts +0 -18
- package/routers/util.ts +0 -231
- package/screenshot/album-image.png +0 -0
- package/screenshot/batchGetSongInfo.png +0 -0
- package/screenshot/batchGetSongLists.png +0 -0
- package/screenshot/downloadQQMusic.png +0 -0
- package/screenshot/get-album-image.png +0 -0
- package/screenshot/get-play-all-data.png +0 -0
- package/screenshot/get-song-album-id.png +0 -0
- package/screenshot/get-song-id.png +0 -0
- package/screenshot/get-song-image.png +0 -0
- package/screenshot/getAlbumInfo.png +0 -0
- package/screenshot/getComments-id.png +0 -0
- package/screenshot/getComments-param.png +0 -0
- package/screenshot/getComments.png +0 -0
- package/screenshot/getDigitalAlbumLists.png +0 -0
- package/screenshot/getLyric-parse.png +0 -0
- package/screenshot/getLyric.png +0 -0
- package/screenshot/getMusicPlay.png +0 -0
- package/screenshot/getMv.png +0 -0
- package/screenshot/getMvByTag.png +0 -0
- package/screenshot/getMvPlay.png +0 -0
- package/screenshot/getNewDisks.png +0 -0
- package/screenshot/getRadioLists.png +0 -0
- package/screenshot/getRanks.png +0 -0
- package/screenshot/getRecommend.png +0 -0
- package/screenshot/getSearchByKey.png +0 -0
- package/screenshot/getSimilarSinger.png +0 -0
- package/screenshot/getSingerAlbum.png +0 -0
- package/screenshot/getSingerDesc.png +0 -0
- package/screenshot/getSingerHotsong.png +0 -0
- package/screenshot/getSingerList.png +0 -0
- package/screenshot/getSingerMv-default.png +0 -0
- package/screenshot/getSingerMv-listen.png +0 -0
- package/screenshot/getSingerMv-time.png +0 -0
- package/screenshot/getSingerStarNum.png +0 -0
- package/screenshot/getSmartbox.png +0 -0
- package/screenshot/getSongInfo.png +0 -0
- package/screenshot/getSongListCategories.png +0 -0
- package/screenshot/getSongListDetail.png +0 -0
- package/screenshot/getSongLists-params.png +0 -0
- package/screenshot/getSongLists.png +0 -0
- package/screenshot/getTicketInfo.png +0 -0
- package/screenshot/getTopLists.png +0 -0
- package/screenshot/gethotkey.png +0 -0
- package/screenshot/just-get-play-url.png +0 -0
- package/screenshot/musicPlay.png +0 -0
- package/screenshot/new-feature-error-tips.png +0 -0
- package/screenshot/normalize-cookie.png +0 -0
- package/screenshot/qq-music-v0.png +0 -0
- package/screenshot/qq-music.png +0 -0
- package/screenshot/song-image.png +0 -0
- package/screenshot/song-quality-128.png +0 -0
- package/screenshot/song-quality-m4a.png +0 -0
- package/scripts/build-images.js +0 -36
- package/scripts/commit-push.sh +0 -103
- package/tests/integration/api/api.test.ts +0 -852
- package/tests/integration/middleware/cors.test.ts +0 -41
- package/tests/setup/jest.setup.ts +0 -15
- package/tests/setup/testUtils.ts +0 -35
- package/tests/unit/util/request.test.ts +0 -177
- package/tsconfig.json +0 -20
- package/tsconfig.test.json +0 -8
- package/types/api.ts +0 -105
- package/types/global.d.ts +0 -26
- package/types/index.d.ts +0 -97
- package/util/apiResponse.ts +0 -97
- package/util/colors.ts +0 -31
- package/util/cookie.ts +0 -40
- package/util/loginUtils.ts +0 -26
- package/util/lyricParse.ts +0 -86
- package/util/request.ts +0 -141
- package/vercel.json +0 -15
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import request from '../../../util/request';
|
|
2
|
-
import { handleApi } from '../../../util/apiResponse';
|
|
3
|
-
import type { ApiOptions } from '../../../types/api';
|
|
4
|
-
|
|
5
|
-
export default async ({ method = 'get', params = {}, option = {} }: ApiOptions) => {
|
|
6
|
-
const data = Object.assign(params, {
|
|
7
|
-
format: 'json',
|
|
8
|
-
outCharset: 'utf-8',
|
|
9
|
-
platform: 'h5',
|
|
10
|
-
needNewCode: 1
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
const options = Object.assign(option, {
|
|
14
|
-
params: data
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
return handleApi(
|
|
18
|
-
request({
|
|
19
|
-
url: '/v8/fcg-bin/fcg_myqq_toplist.fcg',
|
|
20
|
-
method: method as import('axios').Method,
|
|
21
|
-
options,
|
|
22
|
-
isUUrl: 'c'
|
|
23
|
-
}),
|
|
24
|
-
{
|
|
25
|
-
transformData: (response: unknown) => {
|
|
26
|
-
if (typeof response === 'string') {
|
|
27
|
-
const reg = /^\w+\(({[^()]+})\)$/;
|
|
28
|
-
const matches = response.match(reg);
|
|
29
|
-
if (matches) {
|
|
30
|
-
return JSON.parse(matches[1]);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return response;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
);
|
|
37
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import y_common from '../y_common';
|
|
2
|
-
import { handleApi } from '../../../util/apiResponse';
|
|
3
|
-
import type { ApiOptions } from '../../../types/api';
|
|
4
|
-
|
|
5
|
-
export default async ({ method = 'get', params = {}, option = {} }: ApiOptions) => {
|
|
6
|
-
const data = {
|
|
7
|
-
...params,
|
|
8
|
-
format: 'json',
|
|
9
|
-
outCharset: 'utf-8',
|
|
10
|
-
hostUin: 0,
|
|
11
|
-
needNewCode: 0
|
|
12
|
-
};
|
|
13
|
-
const options = {
|
|
14
|
-
...option,
|
|
15
|
-
params: data
|
|
16
|
-
};
|
|
17
|
-
return handleApi(
|
|
18
|
-
y_common({
|
|
19
|
-
url: '/splcloud/fcgi-bin/gethotkey.fcg',
|
|
20
|
-
method: method as string,
|
|
21
|
-
options
|
|
22
|
-
})
|
|
23
|
-
);
|
|
24
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import y_common from '../y_common';
|
|
2
|
-
import { handleApi } from '../../../util/apiResponse';
|
|
3
|
-
import type { ApiOptions } from '../../../types/api';
|
|
4
|
-
|
|
5
|
-
export default async ({ method = 'get', params = {}, option = {} }: ApiOptions) => {
|
|
6
|
-
const data = {
|
|
7
|
-
...params,
|
|
8
|
-
format: 'json',
|
|
9
|
-
outCharset: 'utf-8',
|
|
10
|
-
ct: 24,
|
|
11
|
-
qqmusic_ver: 1298,
|
|
12
|
-
remoteplace: 'txt.yqq.song',
|
|
13
|
-
t: 0,
|
|
14
|
-
aggr: 1,
|
|
15
|
-
cr: 1,
|
|
16
|
-
lossless: 0,
|
|
17
|
-
flag_qc: 0,
|
|
18
|
-
platform: 'yqq.json'
|
|
19
|
-
};
|
|
20
|
-
const options = {
|
|
21
|
-
...option,
|
|
22
|
-
params: data
|
|
23
|
-
};
|
|
24
|
-
return handleApi(
|
|
25
|
-
y_common({
|
|
26
|
-
url: '/soso/fcgi-bin/client_search_cp',
|
|
27
|
-
method: method as string,
|
|
28
|
-
options
|
|
29
|
-
})
|
|
30
|
-
);
|
|
31
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig, Method } from 'axios';
|
|
2
|
-
import y_common from '../y_common';
|
|
3
|
-
|
|
4
|
-
interface GetSmartboxOptions {
|
|
5
|
-
method?: Method | string;
|
|
6
|
-
params?: any;
|
|
7
|
-
option?: AxiosRequestConfig;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export default ({ method = 'get', params = {}, option = {} }: GetSmartboxOptions) => {
|
|
11
|
-
const data = {
|
|
12
|
-
...params,
|
|
13
|
-
format: 'json',
|
|
14
|
-
outCharset: 'utf-8',
|
|
15
|
-
is_xml: 0
|
|
16
|
-
};
|
|
17
|
-
const options: AxiosRequestConfig = {
|
|
18
|
-
...option,
|
|
19
|
-
params: data
|
|
20
|
-
};
|
|
21
|
-
return y_common({
|
|
22
|
-
url: '/splcloud/fcgi-bin/smartbox_new.fcg',
|
|
23
|
-
method: method as Method,
|
|
24
|
-
options
|
|
25
|
-
})
|
|
26
|
-
.then(res => {
|
|
27
|
-
const response = res.data;
|
|
28
|
-
return {
|
|
29
|
-
status: 200,
|
|
30
|
-
body: {
|
|
31
|
-
response
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
})
|
|
35
|
-
.catch(error => {
|
|
36
|
-
console.log('error', error);
|
|
37
|
-
return {
|
|
38
|
-
body: {
|
|
39
|
-
error
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
});
|
|
43
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import request from '../../../util/request';
|
|
2
|
-
import { handleApi } from '../../../util/apiResponse';
|
|
3
|
-
import type { ApiOptions } from '../../../types/api';
|
|
4
|
-
|
|
5
|
-
export default async ({ method = 'get', params = {}, option = {} }: ApiOptions) => {
|
|
6
|
-
const data = Object.assign(params, {
|
|
7
|
-
format: 'json',
|
|
8
|
-
outCharset: 'utf-8',
|
|
9
|
-
utf8: 1,
|
|
10
|
-
start: 0,
|
|
11
|
-
num: 5
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const options = Object.assign(option, {
|
|
15
|
-
params: data
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
return handleApi(
|
|
19
|
-
request({
|
|
20
|
-
url: '/v8/fcg-bin/fcg_v8_simsinger.fcg',
|
|
21
|
-
method: method as import('axios').Method,
|
|
22
|
-
options
|
|
23
|
-
})
|
|
24
|
-
);
|
|
25
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import request from '../../../util/request';
|
|
2
|
-
import { handleApi } from '../../../util/apiResponse';
|
|
3
|
-
import type { ApiOptions } from '../../../types/api';
|
|
4
|
-
|
|
5
|
-
export default async ({ method = 'get', params = {}, option = {} }: ApiOptions) => {
|
|
6
|
-
const data = Object.assign(params, {
|
|
7
|
-
format: 'xml',
|
|
8
|
-
outCharset: 'utf-8',
|
|
9
|
-
utf8: 1,
|
|
10
|
-
r: Date.now()
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
const options = Object.assign(option, {
|
|
14
|
-
params: data
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
return handleApi(
|
|
18
|
-
request({
|
|
19
|
-
url: '/splcloud/fcgi-bin/fcg_get_singer_desc.fcg',
|
|
20
|
-
method: method as import('axios').Method,
|
|
21
|
-
options,
|
|
22
|
-
isUUrl: 'c'
|
|
23
|
-
})
|
|
24
|
-
);
|
|
25
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import request from '../../../util/request';
|
|
2
|
-
import { handleApi } from '../../../util/apiResponse';
|
|
3
|
-
import type { ApiOptions } from '../../../types/api';
|
|
4
|
-
|
|
5
|
-
export default async ({ method = 'get', params = {}, option = {} }: ApiOptions) => {
|
|
6
|
-
const data = Object.assign(params, {
|
|
7
|
-
format: 'json',
|
|
8
|
-
outCharset: 'utf-8',
|
|
9
|
-
cid: 205360581,
|
|
10
|
-
begin: 0
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
const options = Object.assign(option, {
|
|
14
|
-
params: data
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
return handleApi(
|
|
18
|
-
request({
|
|
19
|
-
url: '/mv/fcgi-bin/fcg_singer_mv.fcg',
|
|
20
|
-
method: method as import('axios').Method,
|
|
21
|
-
options
|
|
22
|
-
})
|
|
23
|
-
);
|
|
24
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import request from '../../../util/request';
|
|
2
|
-
import { handleApi } from '../../../util/apiResponse';
|
|
3
|
-
import type { ApiOptions } from '../../../types/api';
|
|
4
|
-
|
|
5
|
-
export default async ({ method = 'get', params = {}, option = {} }: ApiOptions) => {
|
|
6
|
-
const data = Object.assign(params, {
|
|
7
|
-
format: 'json',
|
|
8
|
-
outCharset: 'utf-8',
|
|
9
|
-
utf8: 1,
|
|
10
|
-
rnd: Date.now()
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
const options = Object.assign(option, {
|
|
14
|
-
params: data
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
return handleApi(
|
|
18
|
-
request({
|
|
19
|
-
url: '/rsc/fcgi-bin/fcg_order_singer_getnum.fcg',
|
|
20
|
-
method: method as import('axios').Method,
|
|
21
|
-
options
|
|
22
|
-
})
|
|
23
|
-
);
|
|
24
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { handleApi } from '../../../util/apiResponse';
|
|
2
|
-
import y_common from '../y_common';
|
|
3
|
-
import type { ApiOptions } from '../../../types/api';
|
|
4
|
-
|
|
5
|
-
export default async ({ method = 'get', params = {}, option = {} }: ApiOptions) => {
|
|
6
|
-
const data = {
|
|
7
|
-
...params,
|
|
8
|
-
format: 'json',
|
|
9
|
-
outCharset: 'utf-8'
|
|
10
|
-
};
|
|
11
|
-
const options = {
|
|
12
|
-
...option,
|
|
13
|
-
params: data
|
|
14
|
-
};
|
|
15
|
-
return handleApi(
|
|
16
|
-
y_common({
|
|
17
|
-
url: '/splcloud/fcgi-bin/fcg_get_diss_tag_conf.fcg',
|
|
18
|
-
method: method as string,
|
|
19
|
-
options
|
|
20
|
-
})
|
|
21
|
-
);
|
|
22
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { handleApi } from '../../../util/apiResponse';
|
|
2
|
-
import y_common from '../y_common';
|
|
3
|
-
import type { ApiOptions } from '../../../types/api';
|
|
4
|
-
|
|
5
|
-
export default async ({ method = 'get', params = {}, option = {} }: ApiOptions) => {
|
|
6
|
-
const data = {
|
|
7
|
-
...params,
|
|
8
|
-
format: 'json',
|
|
9
|
-
outCharset: 'utf-8',
|
|
10
|
-
type: 1,
|
|
11
|
-
json: 1,
|
|
12
|
-
utf8: 1,
|
|
13
|
-
onlysong: 0,
|
|
14
|
-
new_format: 1
|
|
15
|
-
};
|
|
16
|
-
const options = {
|
|
17
|
-
...option,
|
|
18
|
-
params: data
|
|
19
|
-
};
|
|
20
|
-
return handleApi(
|
|
21
|
-
y_common({
|
|
22
|
-
url: '/qzone/fcg-bin/fcg_ucc_getcdinfo_byids_cp.fcg',
|
|
23
|
-
method: method as string,
|
|
24
|
-
options
|
|
25
|
-
})
|
|
26
|
-
);
|
|
27
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { handleApi } from '../../../util/apiResponse';
|
|
2
|
-
import y_common from '../y_common';
|
|
3
|
-
import type { ApiOptions } from '../../../types/api';
|
|
4
|
-
|
|
5
|
-
export default async ({ method = 'get', params = {}, option = {} }: ApiOptions) => {
|
|
6
|
-
const data = {
|
|
7
|
-
...params,
|
|
8
|
-
format: 'json',
|
|
9
|
-
outCharset: 'utf-8',
|
|
10
|
-
picmid: 1
|
|
11
|
-
};
|
|
12
|
-
const options = {
|
|
13
|
-
...option,
|
|
14
|
-
params: data
|
|
15
|
-
};
|
|
16
|
-
return handleApi(
|
|
17
|
-
y_common({
|
|
18
|
-
url: '/splcloud/fcgi-bin/fcg_get_diss_by_tag.fcg',
|
|
19
|
-
method: method as string,
|
|
20
|
-
options
|
|
21
|
-
}),
|
|
22
|
-
{
|
|
23
|
-
transformData: (response: unknown) => {
|
|
24
|
-
if (typeof response === 'string') {
|
|
25
|
-
const reg = /^\w+\(([^()]+)\)$/;
|
|
26
|
-
const matches = response.match(reg);
|
|
27
|
-
if (matches) {
|
|
28
|
-
return JSON.parse(matches[1]);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return response;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
);
|
|
35
|
-
};
|
package/module/apis/u_common.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig, Method } from 'axios';
|
|
2
|
-
import request from '../../util/request';
|
|
3
|
-
import * as config from '../config';
|
|
4
|
-
|
|
5
|
-
interface UCommonOptions {
|
|
6
|
-
options?: AxiosRequestConfig;
|
|
7
|
-
method?: Method | string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export default ({ options = {}, method = 'get' }: UCommonOptions) => {
|
|
11
|
-
const opts: AxiosRequestConfig = { ...options };
|
|
12
|
-
|
|
13
|
-
// Merge commonParams into params for query string
|
|
14
|
-
opts.params = { ...config.commonParams, ...(opts.params || {}) };
|
|
15
|
-
|
|
16
|
-
opts.headers = {
|
|
17
|
-
referer: 'https://y.qq.com/portal/player.html',
|
|
18
|
-
host: 'u.y.qq.com',
|
|
19
|
-
'content-type': 'application/x-www-form-urlencoded',
|
|
20
|
-
...(opts.headers || {})
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
if (process.env.DEBUG === 'true') {
|
|
24
|
-
const logOpts = { ...opts, headers: { ...opts.headers, cookie: '[REDACTED]' } };
|
|
25
|
-
console.log('https://u.y.qq.com/cgi-bin/musicu.fcg', { opts: logOpts });
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return request('https://u.y.qq.com/cgi-bin/musicu.fcg', method as Method, opts, 'u');
|
|
29
|
-
};
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import type { ApiFunction, ApiOptions, ApiResponse } from '../../../types/api';
|
|
2
|
-
import { customResponse, errorResponse } from '../../../util/apiResponse';
|
|
3
|
-
import { getGtk, getGuid } from '../../../util/loginUtils';
|
|
4
|
-
|
|
5
|
-
interface LoginSession {
|
|
6
|
-
loginUin: string;
|
|
7
|
-
uin: string;
|
|
8
|
-
cookie: string;
|
|
9
|
-
cookieList: string[];
|
|
10
|
-
cookieObject: Record<string, string>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const REQUEST_TIMEOUT_MS = 10000;
|
|
14
|
-
const DEBUG_ENABLED = process.env.DEBUG === 'true';
|
|
15
|
-
|
|
16
|
-
const debugLog = (message: string, payload?: unknown) => {
|
|
17
|
-
if (DEBUG_ENABLED) {
|
|
18
|
-
console.log(`[checkQQLoginQr] ${message}`, payload ?? '');
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const parseSetCookie = (setCookieHeader: string | null): string[] => {
|
|
23
|
-
if (!setCookieHeader) return [];
|
|
24
|
-
const cookies: string[] = [];
|
|
25
|
-
const parts = setCookieHeader.split(/,(?=\s*[a-zA-Z_]+=)/);
|
|
26
|
-
for (const part of parts) {
|
|
27
|
-
const cookiePair = part.split(';')[0].trim();
|
|
28
|
-
if (cookiePair && cookiePair.includes('=') && cookiePair.split('=')[1]) {
|
|
29
|
-
cookies.push(cookiePair);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return cookies;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const fetchWithTimeout = async (input: string, init: RequestInit = {}, timeout = REQUEST_TIMEOUT_MS) => {
|
|
36
|
-
const controller = new AbortController();
|
|
37
|
-
const timer = setTimeout(() => controller.abort(), timeout);
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
return await fetch(input, {
|
|
41
|
-
...init,
|
|
42
|
-
signal: controller.signal
|
|
43
|
-
});
|
|
44
|
-
} finally {
|
|
45
|
-
clearTimeout(timer);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const buildLoginSession = (cookie: string): LoginSession => {
|
|
50
|
-
const cookieList = cookie
|
|
51
|
-
.split(';')
|
|
52
|
-
.map(item => item.trim())
|
|
53
|
-
.filter(Boolean);
|
|
54
|
-
|
|
55
|
-
const cookieObject: Record<string, string> = {};
|
|
56
|
-
cookieList.forEach(item => {
|
|
57
|
-
const [key, value = ''] = item.split('=');
|
|
58
|
-
if (key && value) {
|
|
59
|
-
cookieObject[key] = value;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const loginUin = cookieObject.uin || '';
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
loginUin,
|
|
67
|
-
uin: loginUin,
|
|
68
|
-
cookie,
|
|
69
|
-
cookieList,
|
|
70
|
-
cookieObject
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const checkQQLoginQr: ApiFunction = async ({ method = 'get', params = {}, option = {} }: ApiOptions): Promise<ApiResponse> => {
|
|
75
|
-
const { ptqrtoken, qrsig } = params;
|
|
76
|
-
if (!ptqrtoken || !qrsig) {
|
|
77
|
-
return errorResponse('参数错误', 400);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
try {
|
|
81
|
-
const url = `https://ssl.ptlogin2.qq.com/ptqrlogin?u1=https%3A%2F%2Fgraph.qq.com%2Foauth2.0%2Flogin_jump&ptqrtoken=${ptqrtoken}&ptredirect=0&h=1&t=1&g=1&from_ui=1&ptlang=2052&action=0-0-1711022193435&js_ver=23111510&js_type=1&login_sig=du-YS1h8*0GqVqcrru0pXkpwVg2DYw-DtbFulJ62IgPf6vfiJe*4ONVrYc5hMUNE&pt_uistyle=40&aid=716027609&daid=383&pt_3rd_aid=100497308&&o1vId=3674fc47871e9c407d8838690b355408&pt_js_version=v1.48.1`;
|
|
82
|
-
|
|
83
|
-
const response = await fetchWithTimeout(url, { headers: { Cookie: `qrsig=${qrsig}` } });
|
|
84
|
-
const data = (await response.text()) || '';
|
|
85
|
-
|
|
86
|
-
const cookieMap = new Map<string, string>();
|
|
87
|
-
const setCookie = (setCookieHeader: string | null) => {
|
|
88
|
-
const cookies = parseSetCookie(setCookieHeader);
|
|
89
|
-
for (const cookie of cookies) {
|
|
90
|
-
const [name] = cookie.split('=');
|
|
91
|
-
cookieMap.set(name, cookie);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
setCookie(response.headers.get('Set-Cookie'));
|
|
96
|
-
|
|
97
|
-
const refresh = data.includes('已失效');
|
|
98
|
-
if (!data.includes('登录成功')) {
|
|
99
|
-
return customResponse(
|
|
100
|
-
{
|
|
101
|
-
isOk: false,
|
|
102
|
-
refresh,
|
|
103
|
-
message: (refresh && '二维码已失效') || '未扫描二维码'
|
|
104
|
-
},
|
|
105
|
-
200
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const allCookie = () => Array.from(cookieMap.values());
|
|
110
|
-
|
|
111
|
-
const urlMatch = data.match(/(?:'((?:https?|ftp):\/\/[^\s/$.?#].[^\s]*)')/g);
|
|
112
|
-
if (!urlMatch || !urlMatch[0]) {
|
|
113
|
-
return errorResponse('Failed to extract checkSigUrl from response', 502);
|
|
114
|
-
}
|
|
115
|
-
const checkSigUrl = urlMatch[0].replace(/'/g, '');
|
|
116
|
-
const checkSigRes = await fetchWithTimeout(checkSigUrl, {
|
|
117
|
-
redirect: 'manual',
|
|
118
|
-
headers: { Cookie: allCookie().join('; ') }
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
const checkSigCookie = checkSigRes.headers.get('Set-Cookie');
|
|
122
|
-
const pSkeyMatch = checkSigCookie?.match(/p_skey=([^;]+)/);
|
|
123
|
-
if (!pSkeyMatch || !pSkeyMatch[1]) {
|
|
124
|
-
return errorResponse('Failed to extract p_skey from response', 502);
|
|
125
|
-
}
|
|
126
|
-
const p_skey = pSkeyMatch[1];
|
|
127
|
-
const gtk = getGtk(p_skey);
|
|
128
|
-
setCookie(checkSigCookie);
|
|
129
|
-
|
|
130
|
-
const authorizeUrl = 'https://graph.qq.com/oauth2.0/authorize';
|
|
131
|
-
|
|
132
|
-
const getAuthorizeData = (g_tk: number) => {
|
|
133
|
-
const data = new FormData();
|
|
134
|
-
data.append('response_type', 'code');
|
|
135
|
-
data.append('client_id', '100497308');
|
|
136
|
-
data.append('redirect_uri', 'https://y.qq.com/portal/wx_redirect.html?login_type=1&surl=https://y.qq.com/');
|
|
137
|
-
data.append('scope', 'get_user_info,get_app_friends');
|
|
138
|
-
data.append('state', 'state');
|
|
139
|
-
data.append('switch', '');
|
|
140
|
-
data.append('from_ptlogin', '1');
|
|
141
|
-
data.append('src', '1');
|
|
142
|
-
data.append('update_auth', '1');
|
|
143
|
-
data.append('openapi', '1010_1030');
|
|
144
|
-
data.append('g_tk', g_tk.toString());
|
|
145
|
-
data.append('auth_time', new Date().toString());
|
|
146
|
-
data.append('ui', getGuid());
|
|
147
|
-
return data;
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
const authorizeRes = await fetchWithTimeout(authorizeUrl, {
|
|
151
|
-
redirect: 'manual',
|
|
152
|
-
method: 'POST',
|
|
153
|
-
body: getAuthorizeData(gtk),
|
|
154
|
-
headers: {
|
|
155
|
-
Cookie: allCookie().join('; ')
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
setCookie(authorizeRes.headers.get('Set-Cookie'));
|
|
159
|
-
|
|
160
|
-
const location = authorizeRes.headers.get('Location');
|
|
161
|
-
const contentType = authorizeRes.headers.get('Content-Type');
|
|
162
|
-
|
|
163
|
-
debugLog('authorize response meta', {
|
|
164
|
-
status: authorizeRes.status,
|
|
165
|
-
redirected: authorizeRes.redirected,
|
|
166
|
-
hasLocation: Boolean(location),
|
|
167
|
-
contentType
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
if (authorizeRes.status < 300 || authorizeRes.status >= 400 || !location) {
|
|
171
|
-
return errorResponse('授权响应异常,未返回跳转地址', 502);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const codeMatch = location.match(/[?&]code=([^&]+)/);
|
|
175
|
-
if (!codeMatch || !codeMatch[1]) {
|
|
176
|
-
debugLog('authorize location parse failed', { location });
|
|
177
|
-
return errorResponse('授权响应中未找到 code 参数', 502);
|
|
178
|
-
}
|
|
179
|
-
const code = codeMatch[1];
|
|
180
|
-
|
|
181
|
-
const getFcgReqData = (g_tk: number, code: string) => {
|
|
182
|
-
const data = {
|
|
183
|
-
comm: {
|
|
184
|
-
g_tk,
|
|
185
|
-
platform: 'yqq',
|
|
186
|
-
ct: 24,
|
|
187
|
-
cv: 0
|
|
188
|
-
},
|
|
189
|
-
req: {
|
|
190
|
-
module: 'QQConnectLogin.LoginServer',
|
|
191
|
-
method: 'QQLogin',
|
|
192
|
-
param: {
|
|
193
|
-
code
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
return JSON.stringify(data);
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
const loginUrl = 'https://u.y.qq.com/cgi-bin/musicu.fcg';
|
|
201
|
-
const loginRes = await fetchWithTimeout(loginUrl, {
|
|
202
|
-
method: 'POST',
|
|
203
|
-
body: getFcgReqData(gtk, code),
|
|
204
|
-
headers: {
|
|
205
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
206
|
-
Cookie: allCookie().join('; ')
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
setCookie(loginRes.headers.get('Set-Cookie'));
|
|
210
|
-
|
|
211
|
-
const sessionCookie = allCookie().join('; ');
|
|
212
|
-
|
|
213
|
-
return customResponse(
|
|
214
|
-
{
|
|
215
|
-
isOk: true,
|
|
216
|
-
message: '登录成功',
|
|
217
|
-
session: buildLoginSession(sessionCookie)
|
|
218
|
-
},
|
|
219
|
-
200
|
|
220
|
-
);
|
|
221
|
-
} catch (error) {
|
|
222
|
-
if ((error as Error).name === 'AbortError') {
|
|
223
|
-
return errorResponse('登录检查超时', 504);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
return errorResponse('登录检查失败', 502);
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
export default checkQQLoginQr;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { ApiFunction, ApiOptions } from '../../../types/api';
|
|
2
|
-
import { customResponse, errorResponse } from '../../../util/apiResponse';
|
|
3
|
-
import { hash33 } from '../../../util/loginUtils';
|
|
4
|
-
|
|
5
|
-
const getQQLoginQr: ApiFunction = async ({ method = 'get', params = {}, option = {} }: ApiOptions) => {
|
|
6
|
-
try {
|
|
7
|
-
const url =
|
|
8
|
-
'https://ssl.ptlogin2.qq.com/ptqrshow?appid=716027609&e=2&l=M&s=3&d=72&v=4&t=0.9698127522807933&daid=383&pt_3rd_aid=100497308&u1=https%3A%2F%2Fgraph.qq.com%2Foauth2.0%2Flogin_jump';
|
|
9
|
-
|
|
10
|
-
const response = await fetch(url);
|
|
11
|
-
const data = await response.arrayBuffer();
|
|
12
|
-
const img = 'data:image/png;base64,' + (data && Buffer.from(data).toString('base64'));
|
|
13
|
-
const cookieHeader = response.headers.get('Set-Cookie');
|
|
14
|
-
const match = cookieHeader?.match(/qrsig=([^;]+)/);
|
|
15
|
-
|
|
16
|
-
if (!match) {
|
|
17
|
-
return errorResponse('Failed to get qrsig from response', 502);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const qrsig = match[1];
|
|
21
|
-
|
|
22
|
-
return customResponse({ img, ptqrtoken: hash33(qrsig), qrsig }, 200);
|
|
23
|
-
} catch (error) {
|
|
24
|
-
return errorResponse('Failed to fetch QQ login QR', 502);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export default getQQLoginQr;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import request from '../../../util/request';
|
|
2
|
-
|
|
3
|
-
// 获取 QQ 用户头像
|
|
4
|
-
export const getUserAvatar = async (params: {
|
|
5
|
-
k?: string;
|
|
6
|
-
uin?: string;
|
|
7
|
-
size?: number;
|
|
8
|
-
}) => {
|
|
9
|
-
const { k, uin, size = 140 } = params;
|
|
10
|
-
|
|
11
|
-
// 如果提供了 k 参数,使用 k 参数获取头像
|
|
12
|
-
if (k) {
|
|
13
|
-
const url = `https://thirdqq.qlogo.cn/g?b=sdk&k=${k}&s=${size}`;
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
avatarUrl: url,
|
|
17
|
-
message: '头像 URL 获取成功'
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// 如果提供了 uin,尝试从 uin 获取头像
|
|
22
|
-
if (uin) {
|
|
23
|
-
const url = `https://q.qlogo.cn/headimg_dl?dst_uin=${uin}&spec=${size}`;
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
avatarUrl: url,
|
|
27
|
-
message: '头像 URL 获取成功'
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
throw new Error('缺少 k 或 uin 参数');
|
|
32
|
-
};
|