mirror of
https://github.com/hect0x7/JMComic-Crawler-Python.git
synced 2025-09-26 22:31:30 +08:00
v.2.0.4: 优化debug和工作流,增加配置文件的介绍,实现工作流的请求失败内容上传 (#53)
This commit is contained in:
parent
85b6bdcaec
commit
1b38daf180
58
assets/config/常用配置介绍.yml
Normal file
58
assets/config/常用配置介绍.yml
Normal file
@ -0,0 +1,58 @@
|
||||
client:
|
||||
# domain: 域名配置,默认是 [],表示运行时自动获取域名。
|
||||
# 可配置特定域名,如下:
|
||||
# 程序会先用第一个域名,如果第一个域名重试n次失败,则换下一个域名重试,以此类推。
|
||||
domain:
|
||||
- jm-comic.org
|
||||
- jm-comic2.cc
|
||||
|
||||
postman:
|
||||
meta_data:
|
||||
# proxies: 代理配置,默认是 null,表示不使用代理。
|
||||
# 以下的写法都可以:
|
||||
# proxies: clash
|
||||
# proxies: v2ray
|
||||
# proxies: 127.0.0.1:7890
|
||||
# proxies:
|
||||
# http: http://127.0.0.1:7890
|
||||
# https: https://127.0.0.1:7890
|
||||
proxies: clash
|
||||
|
||||
# cookies: 帐号配置,默认是 null,表示未登录状态访问JM。
|
||||
# 禁漫的大部分本子,下载是不需要登录的;少部分敏感题材需要登录才能看。
|
||||
# 如果你希望以登录状态下载本子,最简单的方式是配置一下浏览器的cookies,
|
||||
# 不用全部cookies,只要那个叫 AVS 就行。
|
||||
cookies:
|
||||
AVS: qkwehjjasdowqeq # 这个值是乱打的,不能用
|
||||
|
||||
# 下载配置
|
||||
download:
|
||||
cache: true # 如果要下载的文件在磁盘上已存在,不用再下一遍了吧?
|
||||
image:
|
||||
decode: true # JM的原图是混淆过的,要不要还原?
|
||||
suffix: .jpg # 把图片都转为.jpg格式
|
||||
threading:
|
||||
# batch_count: 章节的批量下载图片线程数
|
||||
# 数值大,下得快,配置要求高,对禁漫压力大
|
||||
# 数值小,下得慢,配置要求低,对禁漫压力小
|
||||
# PS: 禁漫网页一般是一次请求50张图
|
||||
batch_count: 30
|
||||
|
||||
|
||||
|
||||
# 文件夹规则配置,决定图片文件存放在你的电脑上的哪个文件夹
|
||||
dir_rule:
|
||||
# base_dir: 根目录。
|
||||
base_dir: D:/a/b/c/
|
||||
|
||||
# rule: 规则dsl。
|
||||
# 本项只建议了解编程的朋友定制,实现在这个类: jmcomic.jm_option.DirRule
|
||||
# 写法:
|
||||
# 1. 以'Bd'开头,表示根目录
|
||||
# 2. 文件夹每增加一层,使用'_'区隔
|
||||
# 3. 文件夹名字表示为 Pxxx/Ayyy,意思是 JmPhotoDetail.xxx / JmAlbumDetail的.yyy。xxx和yyy可以写什么需要看源码。
|
||||
# 下面是示例,表示使用禁漫网站的默认下载方式 [根目录 / 本子id / 章节序号 / 图片文件]
|
||||
# rule: Bd_Aid_Pindex
|
||||
|
||||
# 默认规则是: 根目录 / 章节标题 / 图片文件
|
||||
rule: Bd_Ptitle
|
@ -1,4 +0,0 @@
|
||||
client:
|
||||
domain:
|
||||
- jm-comic.org
|
||||
- jm-comic2.cc
|
@ -2,6 +2,6 @@
|
||||
# 被依赖方 <--- 使用方
|
||||
# config <--- entity <--- toolkit <--- client <--- option
|
||||
|
||||
__version__ = '2.0.3'
|
||||
__version__ = '2.0.4'
|
||||
|
||||
from .api import *
|
||||
|
@ -17,9 +17,10 @@ def download_album(jm_album_id, option=None):
|
||||
|
||||
jm_debug('album',
|
||||
f'本子获取成功: [{album.id}], '
|
||||
f'标题: [{album.title}], '
|
||||
f'作者: [{album.author}], '
|
||||
f'章节数: [{len(album)}]')
|
||||
f'章节数: [{len(album)}]'
|
||||
f'标题: [{album.title}], '
|
||||
)
|
||||
|
||||
def download_photo(photo: JmPhotoDetail,
|
||||
debug_topic='photo',
|
||||
@ -92,11 +93,12 @@ def download_by_photo_detail(photo_detail: JmPhotoDetail,
|
||||
# 下载每个图片的函数
|
||||
def download_image(index, image: JmImageDetail, debug_topic='image'):
|
||||
img_save_path = option.decide_image_filepath(photo_detail, index)
|
||||
debug_tag = f'{image.aid}/{image.filename} [{index + 1}/{len(photo_detail)}]'
|
||||
|
||||
# 已下载过,缓存命中
|
||||
if use_cache is True and file_exists(img_save_path):
|
||||
jm_debug(debug_topic,
|
||||
f'图片已存在: {image.aid}[{image.filename}] → {img_save_path}')
|
||||
f'图片已存在: {debug_tag} ← [{img_save_path}]')
|
||||
return
|
||||
|
||||
# 开始下载
|
||||
@ -107,8 +109,7 @@ def download_by_photo_detail(photo_detail: JmPhotoDetail,
|
||||
)
|
||||
|
||||
jm_debug(debug_topic,
|
||||
f'图片下载完成: {image.aid}/{image.filename}, '
|
||||
f'[{image.img_url}] → [{img_save_path}]')
|
||||
f'图片下载完成: {debug_tag}, [{image.img_url}] → [{img_save_path}]')
|
||||
|
||||
length = len(photo_detail)
|
||||
# 根据图片数,决定下载策略
|
||||
|
@ -1,7 +1,7 @@
|
||||
# 下方填入你要下载的本子的id,一行一个。
|
||||
# 每行的首尾可以有空白字符
|
||||
jm_albums = '''
|
||||
438696
|
||||
452859
|
||||
|
||||
|
||||
'''
|
||||
@ -18,6 +18,7 @@ def get_option():
|
||||
|
||||
# 读取 option 配置文件
|
||||
option = create_option('../assets/config/option_workflow_download.yml')
|
||||
hook_debug(option)
|
||||
|
||||
# 启用 client 的缓存
|
||||
client = option.build_jm_client()
|
||||
@ -38,7 +39,6 @@ def get_option():
|
||||
client.login(username, password, True)
|
||||
print_eye_catching(f'登录禁漫成功')
|
||||
|
||||
hook_debug(option)
|
||||
return option
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ def hook_debug(option):
|
||||
def raise_request_error(cls, resp, msg):
|
||||
from common import write_text, fix_windir_name, format_ts
|
||||
write_text(
|
||||
f'{jm_download_dir}/[请求禁漫失败时的网页内容]_[{format_ts}]_[{fix_windir_name(resp.url)}].html',
|
||||
f'{jm_download_dir}/[请求失败的响应内容]_[{format_ts()}]_[{fix_windir_name(resp.url)}].html',
|
||||
resp.text
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user