From dd33a4f64cbaf13cb8edbf968137103b323aed52 Mon Sep 17 00:00:00 2001 From: psqoycetx <1767552118@qq.com> Date: Sat, 22 Apr 2023 17:47:33 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pipelines.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 pipelines.py diff --git a/pipelines.py b/pipelines.py new file mode 100644 index 0000000..1abcfac --- /dev/null +++ b/pipelines.py @@ -0,0 +1,36 @@ +# Define your item pipelines here +# +# Don't forget to add your pipeline to the ITEM_PIPELINES setting +# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html + + +# useful for handling different item types with a single interface +from itemadapter import ItemAdapter +import subprocess + + +# fdata = pd.read_csv(fpath,encoding='gb18030') +class BilibiliSpiderPipeline: + def process_item(self, item, spider): + title = item['title'] + audio_content = item['video_mp3'] + vedio_content = item['video_mp4'] + content_list = item['content_list'] + print(title) + + # # 保存视频并合成处理 + # with open('video\\' + title + '.mp3', mode='wb') as f: + # f.write(audio_content) + # with open('video\\' + title + '.mp4', mode='wb') as f: + # f.write(vedio_content) + # + # COMMAND = f'ffmpeg -i video\\{title}.mp4 -i video\\{title}.mp3 -c:v copy -c:a aac -strict experimental video\\{title}output.mp4' + # subprocess.run(COMMAND, shell=True) + # + # # 保存弹幕 + # for content in content_list: + # with open('barrage\\' + title + 'barrage.txt', mode='a', encoding='utf-8') as f: + # f.write(content) + # f.write('\n') + + return item