Services/Music/WYYMusicService.cs

(开头部分) 6KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using LisMusic.Common;
using LisMusic.Models;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace LisMusic.Services
{
    public class WYYMusicService : MusicHttpClient, IALLMusicService
    {
        private readonly MusicSource _musicSource = MusicSource.WYY;
        private readonly string WyyIv;
        //private readonly string WyyParameter1;
        private readonly string WyyParameter2;
        private readonly string WyyParameter3;
        private readonly string WyyParameter4;
        private readonly string WyyParameter1_List;
        private readonly string WyyParameter1_Download;

        const string urlGetMusicList = "/weapi/cloudsearch/get/web?csrf_token=";
        const string urlGetMusicDownloadUrl = "/weapi/song/enhance/player/url/v1?csrf_token=";

        public WYYMusicService(HttpClient httpClient, IConfiguration configuration) : base(httpClient)
        {
            httpClient.BaseAddress = new Uri("https://music.163.com/");

            WyyIv = "0102030405060708";
            WyyParameter2 = "010001";
            WyyParameter3 = "00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d813cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7";
            WyyParameter4 = "0CoJUm6Qyw8W8jud";
            WyyParameter1_List = "{{\"hlpretag\":\"<span class=\\\"s-fc7\\\">\",\"hlposttag\":\"</span>\",\"s\":\"{0}\",\"type\":\"1\",\"offset\":\"0\",\"total\":\"true\",\"limit\":\"10\",\"csrf_token\":\"\"}}"; //<<KeyWord>>
            WyyParameter1_Download = "{{\"ids\":\"[{0}]\",\"level\":\"standard\",\"encodeType\":\"aac\",\"csrf_token\":\"\"}}"; //<<ID>>
        }

        public MusicSource MusicSource => _musicSource;

        public async Task<List<MusicInfo>> GetMusicListAsync(string keyWord)
        {
            List<MusicInfo> musicInfos = new List<MusicInfo>();

            try
            {
                string url = urlGetMusicList;
                //两次AES加密,得到 Parameter1(对应参数中的params)
                string strParameter1 = string.Format(WyyParameter1_List, keyWord);
                strParameter1 = Encrypt.AESEncrypt(strParameter1, WyyParameter4, WyyIv);
                string strRandom16 = GetRandomString(16); //随机16位字符
                strParameter1 = Encrypt.AESEncrypt(strParameter1, strRandom16, WyyIv);
                //特定RSA加密,得到 encSecKey
                string encSecKey = RsaEncrypt(strRandom16, WyyParameter2, WyyParameter3);
                string str = await base.PostAsync(url, new { @params = strParameter1, encSecKey = encSecKey });
                JObject jo = JObject.Parse(str);
                for (int i = 0; i < jo["result"]["songs"].Count(); i++)
                {
后面还有 93 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。