吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 3188|回复: 53
上一主题 下一主题
收起左侧

[Python 转载] 网易云缓存.UC!文件转.mp3

  [复制链接]
跳转到指定楼层
楼主
矢岛舞美 发表于 2024-4-13 10:41 回帖奖励
在原帖的基础上进行了一些优化,使用更便捷了!https://www.52pojie.cn/thread-1560121-1-1.html
起因是发现一首网易云收藏的歌居然和昨天听到的不一样了,于是想到从缓存文件提取原歌曲,搜索引擎找了半天还是吾爱的靠谱。
转换界面截图:

成品链接:https://www.123pan.com/s/TKR5Vv-rfr5v.html提取码:7AjK


源码:
[Python] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import os
import tkinter as tk
from tkinter import filedialog
from tkinter.scrolledtext import ScrolledText
import threading
 
def getAllFiles(path):
    # 返回指定目录下的所有文件名
    return [os.path.join(path, f) for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))]
 
def isUcExtension(file):
    # 判断是否是.uc文件
    return file.endswith('.uc!')
 
 
def ucToFlac(file, output_dir):
    # 将指定文件按字节与0xA3进行异或,并对文件格式进行修改
    with open(file, 'rb') as fSource:
        content = bytearray(fSource.read())
    for index in range(len(content)):
        content[index] ^= 0xA3
 
    # 确保输出文件名正确处理,只保留一个.mp3后缀
    # 先移除".uc!"后缀,然后检查并处理重复的.mp3后缀
    output_file_base = file[:-4# 移除".uc!"后缀
    if output_file_base.endswith('.mp3'):
        output_file_name = output_file_base  # 已经是.mp3结尾,无需改动
    else:
        output_file_name = output_file_base + '.mp3'  # 添加.mp3后缀
 
    output_file = os.path.join(output_dir, os.path.basename(output_file_name))
    with open(output_file, 'wb') as fOut:
        fOut.write(content)
    return output_file
 
def convertFilesThread(input_dir, output_dir):
    if not os.path.isdir(input_dir) or not os.path.isdir(output_dir):
        logMessage("错误: 输入或输出目录无效\n")
        return
    files = getAllFiles(input_dir)
    for file in files:
        if isUcExtension(file):
            output_file = ucToFlac(file, output_dir)
            logMessage(os.path.basename(output_file) + ' 转换成功\n')
 
def convertFiles():
    input_dir = input_dir_entry.get()
    output_dir = output_dir_entry.get()
    # 创建并启动一个新线程来执行耗时的转换任务
    threading.Thread(target=convertFilesThread, args=(input_dir, output_dir)).start()
 
def selectInputDir():
    dirname = filedialog.askdirectory()
    if dirname:
        input_dir_entry.delete(0, tk.END)
        input_dir_entry.insert(0, dirname)
 
def selectOutputDir():
    dirname = filedialog.askdirectory()
    if dirname:
        output_dir_entry.delete(0, tk.END)
        output_dir_entry.insert(0, dirname)
 
def logMessage(message):
    # 在文本框中显示信息
    if log_text:
        log_text.config(state=tk.NORMAL)
        log_text.insert(tk.END, message)
        log_text.config(state=tk.DISABLED)
        log_text.see(tk.END)
 
# 创建GUI界面
root = tk.Tk()
root.title("UC文件转MP3工具")
 
# 使用grid布局
tk.Label(root, text="输入目录:").grid(row=0, column=0, sticky='e')
input_dir_entry = tk.Entry(root, width=50)
input_dir_entry.grid(row=0, column=1)
tk.Button(root, text="选择", command=selectInputDir).grid(row=0, column=2)
 
tk.Label(root, text="输出目录:").grid(row=1, column=0, sticky='e')
output_dir_entry = tk.Entry(root, width=50)
output_dir_entry.grid(row=1, column=1)
tk.Button(root, text="选择", command=selectOutputDir).grid(row=1, column=2)
 
tk.Button(root, text="开始转换", command=convertFiles).grid(row=2, column=0, columnspan=3)
 
# 增加一个ScrolledText组件来显示转换日志
log_text = ScrolledText(root, height=10)
log_text.grid(row=3, column=0, columnspan=3, sticky='nsew')
 
# 配置行列权重,确保GUI元素在窗口调整大小时表现良好
root.grid_rowconfigure(3, weight=1)
root.grid_columnconfigure(1, weight=1)
 
root.mainloop()

免费评分

参与人数 6吾爱币 +6 热心值 +6 收起 理由
changesmile + 2 + 1 热心回复!
yeechou + 1 + 1 鼓励转贴优秀软件安全工具和文档!
kylee + 1 + 1 我很赞同!
我是一个外星人 + 1 + 1 用心讨论,共获提升!
yanglinman + 1 谢谢@Thanks!
内瑟斯 + 1 + 1 谢谢@Thanks!

查看全部评分

本帖被以下淘专辑推荐:

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

推荐
78zhanghao87 发表于 2024-4-13 15:12
看懂了,核心代码就是def ucToFlac(file, output_dir):
    # 将指定文件按字节与0xA3进行异或,并对文件格式进行修改
    with open(file, 'rb') as fSource:
        content = bytearray(fSource.read())
    for index in range(len(content)):
        content[index] ^= 0xA3
推荐
tupaly5 发表于 2024-4-13 10:58
3#
27149 发表于 2024-4-13 11:05
4#
shiqiangge 发表于 2024-4-13 11:18
https://www.52pojie.cn/thread-1560121-1-1.html
这是楼主贴子里的地址,赞一个
5#
dingqh 发表于 2024-4-13 11:44
我要给你一个大大的赞
6#
策士 发表于 2024-4-13 11:46
无法启动此程序,因为计算机中丢失 api-ms-win-core-path-l1-1-0.dll娄试重新安装该程序以解决此间题
7#
ningmi370 发表于 2024-4-13 11:48
本帖最后由 ningmi370 于 2024-4-13 12:24 编辑

感谢分享~~~~
8#
Charlotte0 发表于 2024-4-13 11:49
感谢分享,谢谢大大
9#
ZHOUXINGWEI 发表于 2024-4-13 11:54
感谢楼主,感谢分享
10#
wystudio 发表于 2024-4-13 11:56
ningmi370 发表于 2024-4-13 11:48
试试直接改后缀.MP3直接播放

没那么简单,异或加密了的
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2025-4-6 21:33

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表