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