生成百度网盘目录文件
生活随笔
收集整理的這篇文章主要介紹了
生成百度网盘目录文件
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
在裝有百度網(wǎng)盤客戶端并曾經(jīng)至少登錄過(guò)一次網(wǎng)盤賬號(hào)的本機(jī)上找到一個(gè)名為 BaiduYunCacheFileV0.db 的文件;
使用Python腳本撰寫如下代碼:
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
from tkinter import *
from tkinter.filedialog import askopenfilename
from tkinter.filedialog import asksaveasfilename
from tkinter.ttk import *
import sqlite3
def select_db_file():
db_file = askopenfilename(
title="請(qǐng)選擇BaiduYunCacheFileV0.db文件", filetypes=[("db", "*.db")]
)
db.set(db_file)
def select_save_file():
save_file = asksaveasfilename(filetypes=[("文件", "*.txt")])
f.set(save_file + ".txt")
def write_file(file_dict, f, item, gap=""):
if item == "/":
f.write("━" + "/" + "
")
for i in file_dict["/"]:
f.write("┣" + "━" + i + "
")
i = item + i + "/"
if i in file_dict:
write_file(file_dict, f, i, gap="┣━")
else:
gap = "┃ " + gap
for i in file_dict[item]:
f.write(gap + i + "
")
i = item + i + "/"
if i in file_dict:
write_file(file_dict, f, i, gap)
def create_baiduyun_filelist():
file_dict = {}
conn = sqlite3.connect(db.get())
cursor = conn.cursor()
cursor.execute("select * from cache_file")
while True:
value = cursor.fetchone()
if not value:
break
path = value[2]
name = value[3]
size = value[4]
isdir = value[6]
if path not in file_dict:
file_dict[path] = []
file_dict[path].append(name)
else:
file_dict[path].append(name)
with open(f.get(), "w", encoding="utf-8") as fp:
write_file(file_dict, fp, "/")
root = Tk()
root.title("百度云文件列表生成工具")
db_select = Button(root, text=" 選擇DB文件 ", command=select_db_file)
db_select.grid(row=1, column=1, sticky=W, padx=(2, 0), pady=(2, 0))
db = StringVar()
db_path = Entry(root, width=80, textvariable=db)
db_path["state"] = "readonly"
db_path.grid(row=1, column=2, padx=3, pady=3, sticky=W + E)
save_path = Button(root, text="選擇保存地址", command=select_save_file)
save_path.grid(row=2, column=1, sticky=W, padx=(2, 0), pady=(2, 0))
f = StringVar()
file_path = Entry(root, width=80, textvariable=f)
file_path["state"] = "readonly"
file_path.grid(row=2, column=2, padx=3, pady=3, sticky=W + E)
create_btn = Button(root, text="生成文件列表", command=create_baiduyun_filelist)
create_btn.grid(row=3, column=1, columnspan=2, pady=(0, 2))
root.columnconfigure(2, weight=1)
root.mainloop()
將之前所找到的 *.db 文件放入第一個(gè)路徑中,并選擇生成的目錄保存路徑,點(diǎn)擊確定,即可。
作者:艾孜爾江
總結(jié)
以上是生活随笔為你收集整理的生成百度网盘目录文件的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 基于mcp940反编译Minecraft
- 下一篇: KM生存期曲线