from win32com.client import Dispatch
import xlrd
# thunder = Dispatch("ThunderAgent.Agent64.1")
thunder = Dispatch("ThunderAgent.Agent.1")
def to_select(res_src):
book = xlrd.open_workbook(res_src)
table = book.sheet_by_name("Sheet1")
keys = table.col_values(2) # 这是第3列数据,作为字典的key值
vals = table.col_values(1) # 作为值
keys2 = [] vals2 = [] for k in keys:
k = k.strip()
keys2.append(k)
for v in vals:
v = v.strip()
vals2.append(v)
return dict(zip(keys2, vals2))
def to_down(dic, down_src):
print(dic)
for t_src in dic.keys():
# AddTask("下载地址", "另存文件名", "保存目录","任务注释","引用地址","开始模式", "只从原始地址下载","从原始地址下载线程数")
thunder.AddTask(t_src, dic[t_src], down_src, "", "", -1, 0, 5)
thunder.CommitTasks()
if __name__ == "__main__":
res_path = r"D:中文字幕.xlsx"
down_path = r"E:TempTempVideo"
dic = to_select(res_path)
to_down(dic, down_path)