Comments (7)
可以的,按照如下步骤:
- option配置:
dir_rule:
rule: Bd
base_dir: 目标文件夹路径
- 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])
from jmcomic-crawler-python.
非常感谢!自己改了改现在能把收藏的封面全扒下来了。不过还是有一些小问题,有些下载会返回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.
噢这是因为标题里存在特殊字符不能作为文件名
FileNotFoundError是因为标题含有 / 被当作了文件夹分隔符
from jmcomic-crawler-python.
改动以下内容即可
# 让第一页的图片的文件名 = 漫画的标题
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)
- ip地区禁止访问/爬虫被识别 HOT 14
- 【代码优化?】来自@coderabbitai HOT 2
- 想了解一下具体使用什么策略绕过cloudfare检测的呢 HOT 1
- 请问进行登陆之后有获得已收藏本子的方法吗? HOT 11
- 关于通过站内搜索关键字批量下载 HOT 10
- 如何查询排行榜数据 HOT 9
- 把下载下来的所有webp文件都转成一个pdf文件 HOT 24
- 在python上运行失败 HOT 6
- 新插件idea:“离线版” 禁漫天堂 HOT 4
- 发现一个可能的Bug,无法正确匹配上架和更新日期 HOT 22
- 一个关于无效Json的Bug HOT 5
- 如何查找某一类标签的总排行,看app是有的 HOT 2
- 请问有函数能只爬取漫画数据而不下载漫画吗? HOT 11
- BUG:APP_VERSION 应更新为 1.6.5 HOT 2
- 如何获取Album的大标签,如同人、韩漫、3D这种 HOT 7
- 禁漫的重定向很迷,有方法可以获取重定向后的albumID吗 HOT 10
- 如何获得搜索结果数? HOT 1
- 无法正确获取所有domain HOT 6
- categories_filter_gen结果为空 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jmcomic-crawler-python.