Skip to content

Commit 9a98a39

Browse files
author
jadepeng
committed
feat(咪咕): 增加咪咕音乐支持
1 parent 9f6c4cc commit 9a98a39

File tree

6 files changed

+420
-2
lines changed

6 files changed

+420
-2
lines changed

XMusicDownloader/Http/SongDownloader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public void Download()
157157
{
158158
try
159159
{
160-
client.DownloadFile(musicProviders.getDownloadUrl(item, rate), target + "\\" + item.getFileName());
160+
client.DownloadFile(musicProviders.getDownloadUrl(item), target + "\\" + item.getFileName());
161161
break;
162162

163163
}

XMusicDownloader/Program.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Threading.Tasks;
66
using System.Windows.Forms;
77
using XMusicDownloader.Provider;
8+
using XMusicDownloader.Utils;
89

910
namespace XMusicDownloader
1011
{
@@ -16,6 +17,11 @@ static class Program
1617
[STAThread]
1718
static void Main()
1819
{
20+
21+
//String key = AESHelper.AESEncrypt("{\"copyrightId\":\"60054701934\",\"auditionsFlag\":0}", "4ea5c508a6566e76240543f8feb06fd457777be39549c4016436afda65d2330e");
22+
23+
//Console.WriteLine(key);
24+
1925
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; //加上这一句
2026

2127
Application.EnableVisualStyles();

XMusicDownloader/Provider/BaiduProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ private void GetAlbum(string id, List<Song> result)
211211

212212
public string getDownloadUrl(string id, string rate)
213213
{
214-
return HttpHelper.DetectLocationUrl("https://v1.itooi.cn/baidu/url?id=" + id + "&quality=" + rate, DEFAULT_CONFIG);
214+
return HttpHelper.DetectLocationUrl("https://v1.itooi.cn/baidu/url?id=" + id + "&quality=" + rate, DEFAULT_CONFIG);
215215
}
216216

217217
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
using Json;
2+
using Newtonsoft.Json.Linq;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Text.RegularExpressions;
8+
using System.Threading.Tasks;
9+
using XMusicDownloader.Domain;
10+
11+
namespace XMusicDownloader.Provider
12+
{
13+
public class MiguProvider : IMusicProvider
14+
{
15+
static HttpConfig DEFAULT_CONFIG = new HttpConfig
16+
{
17+
Referer = "http://m.music.migu.cn/",
18+
19+
};
20+
21+
public string Name { get; } = "咪咕";
22+
23+
24+
public List<Song> SearchSongs(string keyword, int page, int pageSize)
25+
{
26+
var searchResult = HttpHelper.GET(string.Format("http://m.music.migu.cn/migu/remoting/scr_search_tag?keyword={0}&pgc={1}&rows={2}&type=2", keyword, page, pageSize), DEFAULT_CONFIG);
27+
var result = new List<Song>();
28+
try
29+
{
30+
var searchResultJson = JsonParser.Deserialize(searchResult).musics;
31+
var songIds = new List<string>();
32+
var index = 1;
33+
34+
foreach (var songItem in searchResultJson)
35+
{
36+
var song = new Song
37+
{
38+
id = (string)songItem["id"],
39+
name = (string)songItem["songName"],
40+
singer = (string)songItem["singerName"],
41+
album = (string)songItem["albumName"],
42+
rate = 128,
43+
index = index++,
44+
size = 0,
45+
source = Name,
46+
url = (string)songItem["mp3"],
47+
duration = 0
48+
};
49+
50+
result.Add(song);
51+
}
52+
53+
}
54+
catch (Exception ex)
55+
{
56+
Console.WriteLine(ex.Message);
57+
}
58+
return result;
59+
60+
}
61+
62+
public string getDownloadUrl(Song song)
63+
{
64+
return song.url;
65+
66+
}
67+
// http://music.taihe.com/songlist/516288502
68+
// http://music.taihe.com/album/182772
69+
70+
public bool Support(string url)
71+
{
72+
return false;
73+
}
74+
75+
Regex regex = new Regex("(\\d+)");
76+
77+
public List<Song> GetSongList(string url)
78+
{
79+
var result = new List<Song>();
80+
return result;
81+
}
82+
83+
84+
public string getDownloadUrl(string id, string rate)
85+
{
86+
return HttpHelper.DetectLocationUrl("https://v1.itooi.cn/baidu/url?id=" + id + "&quality=" + rate, DEFAULT_CONFIG);
87+
}
88+
89+
}
90+
}

0 commit comments

Comments
 (0)