懶人聽(tīng)書(shū)緩存音頻文件名解碼
本文為知乎 千尺浪 所做。 但是他代碼打錯(cuò)了,我已經(jīng)把代碼更正。
1. 手機(jī)端批量下載音頻
新人先領(lǐng)個(gè)7天會(huì)員,把想聽(tīng)的專輯或小說(shuō)下載下來(lái)慢慢聽(tīng)!
點(diǎn)擊"目錄",輸入要下載的章節(jié),默認(rèn)50集,單次下載不允許超過(guò)100集
2. 將緩存文件拷貝至電腦
緩存的文件位于
/storage/emulated/0/tingshu/專輯名文件夾? 在手機(jī)上是隱藏的可以用MT2查看器轉(zhuǎn)到PC上。
3. 文件名批量解碼

# -*- coding: utf-8 -*- import os,sys import base64 import tkinter as tk from tkinter import filedialog def rename(): ? ?'''打開(kāi)選擇文件夾對(duì)話框''' ? ?root = tk.Tk() ? ?root.withdraw() ? ?path = os.path.normpath(filedialog.askdirectory())#獲得選擇好的文件夾 ? ?filelist = os.listdir(path) ? #該文件夾下所有的文件(包括文件夾) ? ? ?i=0 ? ?for files in filelist: ? #遍歷所有文件 ? ? ? ?try: ? ? ? ? ? ?Olddir = os.path.join(path, files) ? ?#原來(lái)的文件路徑 ? ? ? ? ? ?if os.path.isdir(Olddir): ? ? ? #如果是文件夾則跳過(guò) ? ? ? ? ? ? ? ? ? ?continue ? ? ? ? ? ?if files[0] == "." : #開(kāi)頭字符. ? ? ? ? ? ? ? ?#涉及網(wǎng)絡(luò)url傳輸,其中的+和/會(huì)被轉(zhuǎn)義成_和- ? ? ? ? ? ? ? ?#替換多個(gè)不同的字符串: translate() ? ? ? ? ? ? ? ?file_ed=files.translate(str.maketrans({'_': '/', '-': '+'})) ? ? ? ? ? ? ? ? ? ? ? ?decodestr=base64.b64decode(file_ed) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?#文件名 ? ? ? ? ? ? ? ?file_name=decodestr.decode('utf-8', errors='ignore') ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?filetype = ".mp3" ? ? ? #文件擴(kuò)展名 ? ? ? ? ? ? ? ?Newdir = os.path.normpath(os.path.join(path, file_name + filetype)) ? #新的文件路徑 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?os.rename(Olddir, Newdir) ? ?#重命名 ? ? ? ? ? ? ? ?i=i+1 ? ? ? ? ? ? ? ?print(files + " -> " + file_name) ? ? ? ? ? ? ? ? ? ? ? ?except Exception as e: ? ? ? ? ? ? ? ? print (str(e)) ? ?print("轉(zhuǎn)換完成文件名共計(jì)" + str(i) +"個(gè)") if __name__ == '__main__': ? ?rename()
4. 解碼后的音頻為MP3格式,你上傳至百度網(wǎng)盤(pán),在手機(jī)端順序播放音頻。
下面是軟件
鏈接:https://pan.baidu.com/s/1Pgl-uETng9g74eYSUU93zQ?
提取碼:6899

不能轉(zhuǎn)載。