GithubHelp home page GithubHelp logo

Comments (7)

hect0x7 avatar hect0x7 commented on August 25, 2024

可以的,按照如下步骤:

  1. option配置:
dir_rule:
  rule: Bd
  base_dir: 目标文件夹路径
  1. python代码:
from jmcomic import *


def init():
    # 只下载第一页
    class MyDownloader(JmDownloader):

        def do_filter(self, detail: DetailEntity):
            if detail.is_photo():
                return detail[:1]

            return super().do_filter(detail)

    # 让第一页的图片的文件名 = 漫画的标题
    class MyOption(JmOption):

        def decide_image_filename(self, image: JmImageDetail) -> str:
            if image.index == 1:
                return image.from_photo.from_album.name

            return super().decide_image_filename(image)

    JmModuleConfig.CLASS_DOWNLOADER = MyDownloader
    JmModuleConfig.CLASS_OPTION = MyOption


# 准备步骤,自定义替换了一些下载组件
init()

# 下面就正常使用下载api即可
op = create_option('你的option文件路径')
op.download_album([123, 456])

效果如下:
image

from jmcomic-crawler-python.

lpf1143 avatar lpf1143 commented on August 25, 2024

非常感谢!自己改了改现在能把收藏的封面全扒下来了。不过还是有一些小问题,有些下载会返回FileNotFoundError或者是OSError

2023-12-13 19:50:52:【image.after】图片下载完成: 479421/00001.webp [1/29], [https://cdn-msp.18comic.vip/media/photos/479421/00001.webp] → [C:/Users/xxx/Documents/jmcomic/bysa/(C102) [绅士仓库汉化] [FRAC (もとみやみつき)] メイドトリップ (オリジナル) [DL版].webp]
2023-12-13 19:50:52:【photo.after】章节下载完成: [479421] (479421[1/1])
2023-12-13 19:50:52:【album.after】本子下载完成: [479421]
2023-12-13 19:50:52:【html】https://18comic.vip/album/457664
Exception in thread Thread-688:
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\threading.py", line 926, in _bootstrap_inner
    self.run()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\jmcomic\jm_downloader.py", line 81, in <lambda>
    apply=lambda image: self.download_by_image_detail(image, client),
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\jmcomic\jm_downloader.py", line 105, in download_by_image_detail
    decode_image=decode_image,
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\jmcomic\jm_client_interface.py", line 271, in download_by_image_detail
    decode_image=decode_image,
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\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 "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\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 "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\jmcomic\jm_client_interface.py", line 81, in transfer_to
    path,
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\jmcomic\jm_toolkit.py", line 757, in decode_and_save
    cls.save_image(img_decode, decoded_save_path)
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\jmcomic\jm_toolkit.py", line 709, in save_image
    image.save(filepath)
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PIL\Image.py", line 2429, in save
    fp = builtins.open(filename, "w+b")
FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/xxx/Documents/jmcomic/bysa/露出導演 / 想看妳露出羞恥的模樣 [甜米らくれ] 露出女子高生×映画男子 恥じらう君が見たいんだ.webp'

2023-12-13 19:50:53:【photo.after】章节下载完成: [496057] (246934[67/67])
Exception in thread Thread-690:
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\threading.py", line 926, in _bootstrap_inner
    self.run()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\jmcomic\jm_downloader.py", line 81, in <lambda>
    apply=lambda image: self.download_by_image_detail(image, client),
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\jmcomic\jm_downloader.py", line 105, in download_by_image_detail
    decode_image=decode_image,
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\jmcomic\jm_client_interface.py", line 271, in download_by_image_detail
    decode_image=decode_image,
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\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 "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\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 "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\jmcomic\jm_client_interface.py", line 81, in transfer_to
    path,
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\jmcomic\jm_toolkit.py", line 757, in decode_and_save
    cls.save_image(img_decode, decoded_save_path)
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\jmcomic\jm_toolkit.py", line 709, in save_image
    image.save(filepath)
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\PIL\Image.py", line 2429, in save
    fp = builtins.open(filename, "w+b")
OSError: [Errno 22] Invalid argument: 'C:/Users/xxx/Documents/jmcomic/bysa/[葱鱼个人呢汉化] [ろうか] 今日、 泊めてくれませんか? [**翻訳] [DL版].webp'```

from jmcomic-crawler-python.

hect0x7 avatar hect0x7 commented on August 25, 2024

噢这是因为标题里存在特殊字符不能作为文件名
FileNotFoundError是因为标题含有 / 被当作了文件夹分隔符

from jmcomic-crawler-python.

hect0x7 avatar hect0x7 commented on August 25, 2024

改动以下内容即可

# 让第一页的图片的文件名 = 漫画的标题
class MyOption(JmOption):

    def decide_image_filename(self, image: JmImageDetail) -> str:
        if image.index == 1:
            name = image.from_photo.from_album.name # 改这里
            return fix_windir_name(name)

        return super().decide_image_filename(image)

from jmcomic-crawler-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.