网易云在线缓存歌曲解码
felicx 化神

前言

用手机网易云听歌时,网易云会帮你缓存歌曲文件,是.uc!文件,要想在电脑端回放,需要解码成.flac格式。这里提供一种方法。

解决

首先将缓存目录下的.uc!文件提取到电脑,将每个文件按字节与0xA3进行异或,并对文件格式修改成.flac即可。

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
import os

def getCurPath():
return os.getcwd()

def getAllFiles(data_path):
# 返回data_path目录下的所有文件名
return [f for f in os.listdir(data_path)]

def isUcExtension(file):
# 判断是否是.uc文件
if len(file) >= 4 and file[-4:] == '.uc!':
return True
else:
return False

def ucToFlac(file):
# 将当前文件按字节与0xA3进行异或,并对文件格式进行修改
fSource = open(file, 'rb')
fOut = open(file[:-4] + '.flac', 'wb')
content = bytearray(fSource.read())
for index in range(len(content)):
content[index] ^= 0xA3
fOut.write(content)
fSource.close()
fOut.close()

if __name__ == '__main__':
origin_path = "Music"
cur_path = getCurPath()
total_origin_path = os.path.join(cur_path, origin_path)

# 函数调用:将当前目录下所有的.uc文件自动解码成.flac文件
files = getAllFiles(total_origin_path)
for file in files:
if isUcExtension(os.path.join(total_origin_path, file)):
ucToFlac(os.path.join(total_origin_path, file))
print(file[:-4] + '.flac' + '转换成功')
 评论
评论插件加载失败
正在加载评论插件
由 Hexo 驱动 & 主题 Keep
访客数 访问量