hect0x7 / JMComic-Crawler-Python

Python API for JMComic | 提供Python API访问禁漫天堂,同时支持网页端和移动端 | 禁漫天堂GitHub Actions下载器🚀
https://jmcomic.readthedocs.io/zh-cn/latest/option_file_syntax/#
MIT License
881 stars 2.08k forks source link

[Bug] 部分图片下载失败 #286

Closed lalalaXman closed 1 month ago

lalalaXman commented 1 month ago

注意事项

发生Bug时,你的使用方式?

Python代码

你是否在禁漫官方网页或APP,验证过相应的功能是正常的?

测试过,禁漫官方功能正常

option配置+源码/命令

Code

option = jmcomic.create_option_by_file("xxxx")
option.download_album(album_id)

Option

version: '2.1'
client:
  domain:
    html: [18comic.vip]
    api: [www.jmapiproxyxxx.one]
  impl: api
  retry_times: 5
download:
  cache: true
  image:
    decode: true
    suffix: null
  threading:
    image: 30
    photo: 8
log: true
plugins:
  valid: log
  after_init:
    - plugin: login
      kwargs:
        username: ${JM_USERNAME}
        password: ${JM_PASSWORD}
dir_rule:
  base_dir: ${JM_PATH_COMICS}
  rule: Bd_Atitle_Pindex

你预期的结果,与实际结果的差别

下载时出现部分图片失败,多次尝试,这几张图片都会报错。直接打开url 可以正常加载。

其他信息

# 错误日志
[2024-09-21 00:29:56] [Thread-363 (<lambda>)]:【image.failed】图片下载失败: [https://cdn-msp.jmapiproxy2.cc/media/photos/188573/00004.webp], 异常: encoding error 5
Exception in thread Thread-363 (<lambda>):
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniconda/base/envs/jmd/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "/opt/homebrew/Caskroom/miniconda/base/envs/jmd/lib/python3.12/threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/jmd/lib/python3.12/site-packages/jmcomic/jm_downloader.py", line 89, in <lambda>
    apply=lambda image: self.download_by_image_detail(image, client),
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniconda/base/envs/jmd/lib/python3.12/site-packages/jmcomic/jm_downloader.py", line 114, in download_by_image_detail
    client.download_by_image_detail(
  File "/opt/homebrew/Caskroom/miniconda/base/envs/jmd/lib/python3.12/site-packages/jmcomic/jm_client_interface.py", line 267, in download_by_image_detail
    return self.download_image(
           ^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniconda/base/envs/jmd/lib/python3.12/site-packages/jmcomic/jm_client_interface.py", line 256, in download_image
    return self.save_image_resp(decode_image, img_save_path, img_url, resp, scramble_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniconda/base/envs/jmd/lib/python3.12/site-packages/jmcomic/jm_client_interface.py", line 260, in save_image_resp
    resp.transfer_to(img_save_path, scramble_id, decode_image, img_url)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/jmd/lib/python3.12/site-packages/jmcomic/jm_client_interface.py", line 75, in transfer_to
    JmImageTool.decode_and_save(
  File "/opt/homebrew/Caskroom/miniconda/base/envs/jmd/lib/python3.12/site-packages/jmcomic/jm_toolkit.py", line 762, in decode_and_save
    cls.save_image(img_src, decoded_save_path)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/jmd/lib/python3.12/site-packages/jmcomic/jm_toolkit.py", line 740, in save_image
    image.save(filepath)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/jmd/lib/python3.12/site-packages/PIL/Image.py", line 2568, in save
    save_handler(self, fp, filename)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/jmd/lib/python3.12/site-packages/PIL/WebPImagePlugin.py", line 336, in _save
    data = _webp.WebPEncode(
           ^^^^^^^^^^^^^^^^^
ValueError: encoding error 5
hect0x7 commented 1 month ago

这个图片其实是jpg格式,但是禁漫给的url后缀是webp。导致python代码以webp格式保存出错了。 这个问题应该暂时只能通过配置图片格式转换来解决:

download:
  image:
    suffix: .jpg
lalalaXman commented 1 month ago

Ok, 可以了, thx.