From da3384b6d4399aae301bfd3447aac7aa2b45460d Mon Sep 17 00:00:00 2001 From: helloplhm-qwq Date: Sat, 6 Jan 2024 15:59:51 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BC=98=E7=A7=80=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/__init__.py | 5 ++- modules/tx/__init__.py | 3 ++ modules/tx/mv.py | 82 ++++++++++++++++++++++++++++++++++++++---- 3 files changed, 83 insertions(+), 7 deletions(-) diff --git a/modules/__init__.py b/modules/__init__.py index f665bd7..e0bec6a 100644 --- a/modules/__init__.py +++ b/modules/__init__.py @@ -210,4 +210,7 @@ async def other_with_query(method, source, t, _, query): 'code': 2, 'msg': e.args[0], 'data': None, - } \ No newline at end of file + } + +async def info_with_query(source, songid, _, query): + return await other('info', source, songid, None) \ No newline at end of file diff --git a/modules/tx/__init__.py b/modules/tx/__init__.py index 3cb4833..84c7a1f 100644 --- a/modules/tx/__init__.py +++ b/modules/tx/__init__.py @@ -11,6 +11,7 @@ from .musicInfo import getMusicInfo as _getInfo from .utils import formatSinger from .lyric import getLyric as _getLyric +from .mv import getMvPlayURLandInfo as _getMvInfo from common import utils from . import refresh_login @@ -79,3 +80,5 @@ async def info(songid): async def lyric(songId): return await _getLyric(songId) +async def mv(vid): + return await _getMvInfo(vid) \ No newline at end of file diff --git a/modules/tx/mv.py b/modules/tx/mv.py index 43ff3b2..1c0b39c 100644 --- a/modules/tx/mv.py +++ b/modules/tx/mv.py @@ -1,10 +1,80 @@ # ---------------------------------------- -# - mode: python - -# - author: helloplhm-qwq - -# - name: mv.py - -# - project: lx-music-api-server - -# - license: MIT - +# - mode: python - +# - author: helloplhm-qwq - +# - name: mv.py - +# - project: lx-music-api-server - +# - license: MIT - # ---------------------------------------- # This file is part of the "lx-music-api-server" project. -# 没做 \ No newline at end of file +import asyncio +import json +from .utils import signRequest + + +async def getMvPlayURLandInfo(vid): + info = signRequest({ + "comm": {"ct": 24, "cv": 4747474}, + "mvinfo": { + "module": "video.VideoDataServer", + "method": "get_video_info_batch", + "param": { + "vidlist": [vid], + "required": [ + "vid", + "type", + "sid", + "cover_pic", + "duration", + "singers", + "video_switch", + "msg", + "name", + "desc", + "playcnt", + "pubdate", + "isfav", + "gmid", + "songmid" + ], + }, + }, + }, True) + urlreq = signRequest({ + "comm": { + "ct": 24, + "cv": 4747474, + "g_tk": 812935580, + "uin": 0, + "format": "json", + "platform": "yqq" + }, + "mvUrl": { + "module": "gosrf.Stream.MvUrlProxy", + "method": "GetMvUrls", + "param": { + "vids": [vid], + "request_typet": 10001, + "addrtype": 3, + "format": 264 + } + } + }) + res = await asyncio.gather(info, urlreq) + i = res[0] + # output i with formatted json + print(json.dumps(i.json(), indent=2, ensure_ascii = False)) + url = res[1] + file_info = {} + urlbody = url.json() + if (urlbody['code'] == 0 and urlbody['mvUrl']['code'] == 0): + for u in url['mvUrl']['data'][vid]['mp4']: + if (u['filetype'] == 0): + if (u['fileSize']): + pass + pass + pass + pass + pass + +