From f680ac54bcd5e14be3c2833ced6d9daff0884544 Mon Sep 17 00:00:00 2001 From: Daniel2022 <1415889804@qq.com> Date: Fri, 24 Jul 2020 19:36:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9ACtrl+C=E9=80=80?= =?UTF-8?q?=E5=87=BA=E6=97=B6=E4=BF=9D=E5=AD=98=E6=95=B0=E6=8D=AE=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=A8=BF=E4=BB=B6=E6=97=B6=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=EF=BC=8C=E4=BB=A5=E5=85=8D=E6=84=8F=E5=A4=96?= =?UTF-8?q?=E9=80=80=E5=87=BA=E4=BD=BF=E5=B7=B2=E6=B7=BB=E5=8A=A0=E7=A8=BF?= =?UTF-8?q?=E4=BB=B6=E4=BF=A1=E6=81=AF=E6=9C=AA=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 10 ++++++++-- module/bililib.py | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) 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,{