-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathNetMusicCacheDecrypt.cs
75 lines (65 loc) · 2.15 KB
/
NetMusicCacheDecrypt.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ATL.AudioData;
using ATL;
using System.IO;
namespace WindowsFormsApp1
{
/// <summary>
/// 网易云缓存解密
/// </summary>
public class NetMusicCacheDecrypt : BaseCacheDecrypt
{
public override string AcceptableExtension
{
get
{
return ".uc";
}
}
string cut(string str,string start,string end)
{
var startIndex = str.IndexOf(start);
if (startIndex == -1)
{
return "";
}
startIndex += start.Length;
var endIndex = str.IndexOf(end, startIndex);
if (endIndex == -1)
{
return "";
}
return str.Substring(startIndex, endIndex - startIndex);
}
public override byte[] Decrypt(byte[] cacheFileData)
{
for (var i = 0; i < cacheFileData.Length; i++)
{
// 异或0xa3
cacheFileData[i] ^= 0xa3;
}
var fileName = new FileInfo(currentCacheFile).Name;
var songId = fileName.Substring(0, fileName.IndexOf("-"));
var html = HttpHelper.SendGet("http://music.163.com/song?id=" + songId);
if (html.Length > 0)
{
var title = cut(html, "<title>", "</title>").Trim();
var tempFile = currentCacheFile+ Guid.NewGuid().ToString();
File.WriteAllBytes(tempFile, cacheFileData);
Track theTrack = new Track(tempFile);
// 父亲写的散文诗(时光版) - 许飞 - 单曲 - 网易云音乐
theTrack.Artist = cut(title, "-", "-").Trim();
theTrack.Title = title.Substring(0, title.IndexOf("-")).Trim();
// Save modifications on the disc
theTrack.Save();
cacheFileData = File.ReadAllBytes(tempFile);
File.Delete(tempFile);
}
return cacheFileData;
}
}
}