79 lines
2.6 KiB
Python
79 lines
2.6 KiB
Python
# Define here the models for your scraped items
|
|
#
|
|
# See documentation in:
|
|
# https://docs.org/en/latest/topics/items.html
|
|
from scrapy.item import Item, Field
|
|
from Comics.utils.Constant import ComicPath
|
|
from scrapy.loader.processors import TakeFirst, MapCompose, Join
|
|
|
|
def serialize_to_chinese(value):
|
|
return ComicPath.chinese_convert(value)
|
|
|
|
def serialize_to_fix_file(value):
|
|
file = ComicPath.chinese_convert(value)
|
|
return ComicPath.fix_file_name(file)
|
|
|
|
class ComicOItem(Item):
|
|
name = Field()
|
|
chapterItem = Field()
|
|
|
|
class ComicItem(Item):
|
|
# 编号
|
|
index = Field(output_processor=TakeFirst())
|
|
# 漫画名
|
|
name = Field(serializer=serialize_to_fix_file, output_processor=TakeFirst())
|
|
# 章节名
|
|
chapter = Field(serializer=serialize_to_fix_file, output_processor=TakeFirst())
|
|
# 图片链接
|
|
list_img = Field()
|
|
# 作者
|
|
author = Field(serialize_to_chinese=serialize_to_chinese, output_processor=TakeFirst())
|
|
# 封面链接
|
|
icon = Field(output_processor=TakeFirst())
|
|
# 标签
|
|
tags = Field(serializer=serialize_to_chinese, output_processor=TakeFirst())
|
|
# 概述
|
|
dep = Field(serializer=serialize_to_chinese, output_processor=TakeFirst())
|
|
# 时间
|
|
date = Field(output_processor=TakeFirst())
|
|
# 流派
|
|
genre = Field(output_processor=TakeFirst())
|
|
# 年龄分级
|
|
age_rating = Field(output_processor=TakeFirst())
|
|
|
|
images = Field()
|
|
images_name = Field()
|
|
|
|
class ImageItem(Item):
|
|
image_name = Field()
|
|
image_url = Field()
|
|
image_path = Field()
|
|
|
|
def serializer_info_writer(value):
|
|
list_value = []
|
|
str(value).replace("&", " ")
|
|
for v in str(value).split(" "):
|
|
list_value.append(v)
|
|
return ",".join(list_value)
|
|
|
|
class ComicInfoItem(Item):
|
|
Title = Field(info='chapter')#"章节名",True]
|
|
Series = Field(info='name')# ","漫画名",True]
|
|
Number = Field(info='index')# ","编号",True]
|
|
SeriesGroup = Field()# ","别名",False]
|
|
Summary = Field(info='dep')# ","概述",True]
|
|
Year = Field()# ","年",False]
|
|
Month = Field()# ","月",False]
|
|
Day = Field()# ","日",False]
|
|
Writer = Field(info='author',serializer=serializer_info_writer)# "作者",True]
|
|
Publisher = Field()# ","出版社",False]
|
|
Genre = Field(info='genre')# ","流派",True]
|
|
Tags = Field(info='tags')# ","标签",True]
|
|
Web = Field()# ","主页",False]
|
|
PageCount = Field()# ","总页数",True]
|
|
LanguageISO = Field()#","语言",True]
|
|
AgeRating = Field(info='age_rating')#","年龄分级",False]
|
|
Pages = Field(info='images_name')#","页码",True]
|
|
# ComicInfo.xml and ComicChapter.json end
|
|
|