fix
This commit is contained in:
parent
38deb27d7e
commit
99c7026dff
@ -23,9 +23,6 @@ class ComicsPipeline:
|
||||
|
||||
# item就是yield后面的对象
|
||||
def process_item(self, item, spider):
|
||||
|
||||
checkUtils().export_error(item)
|
||||
|
||||
if isinstance(item, ComicItem):
|
||||
# 'output/rm_comic/json/壞X/第1話 壞X'
|
||||
if os.path.exists(ComicPath.CBZ(item=item)):
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import scrapy,logging,time,os
|
||||
import scrapy,logging,time,os,skip
|
||||
from Comics.items import ComicItem
|
||||
from Comics.loader import ComicLoader
|
||||
from Comics.utils.Constant import ComicPath
|
||||
|
||||
@ -6,19 +6,21 @@ from Comics.utils.FileUtils import fileUtils as fu
|
||||
from Comics.loader import ComicEntity
|
||||
|
||||
class checkUtils:
|
||||
|
||||
def read(self, item):
|
||||
file = os.path.join(OUTPUT_DIR, item[PROJECT_KEY][0], "error_comics.json")
|
||||
return ItemImport().import_obj(file)
|
||||
#
|
||||
# 检测某一章节是否连续错误
|
||||
def export_error(self, item):
|
||||
file = os.path.join(OUTPUT_DIR, item[PROJECT_KEY][0], "error_comics.json")
|
||||
error_comic = ItemImport().import_obj(file)
|
||||
if not self.is_error(item):
|
||||
error_comic = self.read(item)
|
||||
error_comic.append({ "name" : item['name'], "chapter" : item['chapter'], "date" : ComicPath().getYearMonthDay()})
|
||||
fu.save_file(file, json.dumps(error_comic))
|
||||
|
||||
def is_error(self, item):
|
||||
file = os.path.join(OUTPUT_DIR, item[PROJECT_KEY][0], "error_comics.json")
|
||||
error_comic = ItemImport().import_obj(file)
|
||||
try:
|
||||
for error_c in eval(error_comic):
|
||||
for error_c in eval(self.read(item)):
|
||||
(name, chatper, date) = [error_c['name'], error_c['chapter'], error_c['date']]
|
||||
if item['name'] == name and item['chapter'] == chatper:
|
||||
return True
|
||||
|
||||
Loading…
Reference in New Issue
Block a user