diff --git a/main.py b/main.py index 57e4a82..ad1bf52 100644 --- a/main.py +++ b/main.py @@ -43,10 +43,13 @@ firststart = True -def exitAction(): +def save(): savedata = open(savefile,'wb') pickle.dump(item_group,savedata) savedata.close() + +def exitAction(): + save() os.system('cls') print("脚本已退出,记录已保存至" + savefile) os._exit(0) @@ -149,6 +152,7 @@ def action(self): item = bili_Video(bvid=bvid) item_group.append(item) print("已添加%s\n%s" % (bvid,item.title)) + save() elif self.keyword.lower() == 'd': item_group.pop(len(item_group)-1) elif self.keyword.lower() == 'cl': @@ -378,4 +382,6 @@ def switch(self): State.statetag = NORMAL except IndexError: print("Error:索引错误") - input(ErrorMeassage) \ No newline at end of file + input(ErrorMeassage) + except KeyboardInterrupt: + exitAction() \ No newline at end of file diff --git a/module/bililib.py b/module/bililib.py index 28aefa9..4d8762c 100644 --- a/module/bililib.py +++ b/module/bililib.py @@ -131,7 +131,8 @@ def show(self): return string def autodownload(self,qn=80): for i in range(len(self.video_list)): - self.video_list[i].load() + if not self.video_list[i].AbleToDownload: + self.video_list[i].load() self.video_list[i].Flv_downloader(qn=qn,auto=True) class Videos: @@ -142,6 +143,7 @@ def __init__(self,avid=None,bvid=None,cid=None,page=1,title=None,subtitle=None): self.page = page self.title = title self.subtitle = subtitle + self.AbleToDownload = False self.referer = 'https://www.bilibili.com/video/%s?page=%d' % (self.bvid, self.page) def load(self): response = requests.get(GET_VIDEO_DOWNLOAD_URL,{