You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.3 KiB
37 lines
1.3 KiB
# 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
|