mirror of
https://github.com/Xtao-Labs/Telegram-Custom-Artwork-Api.git
synced 2024-12-04 20:11:40 +00:00
23 lines
656 B
Python
23 lines
656 B
Python
|
import contextlib
|
||
|
|
||
|
from typing import List
|
||
|
from pyncm import GetCurrentSession, apis
|
||
|
from defs import Music
|
||
|
|
||
|
|
||
|
class Netease:
|
||
|
@staticmethod
|
||
|
async def get(keyword: str) -> List[Music]:
|
||
|
# 海外用户
|
||
|
GetCurrentSession().headers["X-Real-IP"] = "118.88.88.88"
|
||
|
try:
|
||
|
req = apis.cloudsearch.GetSearchResult(keyword)
|
||
|
songs = req["result"]["songs"]
|
||
|
except Exception:
|
||
|
return []
|
||
|
results = []
|
||
|
for i in songs:
|
||
|
with contextlib.suppress(Exception):
|
||
|
results.append(Music(i["name"], i["al"]["picUrl"].replace("http:", "https:")))
|
||
|
return results
|