hect0x7 / JMComic-Crawler-Python

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

按照album压缩 异常 #223

Closed bestsort closed 2 months ago

bestsort commented 2 months ago

执行失败:

[2024-04-09 20:45:28] [MainThread]:【plugin.invoke】调用插件: [zip]
[2024-04-09 20:45:28] [MainThread]:【plugin.error】插件 [zip],运行遇到未捕获异常,异常信息: ['NoneType' object has no attribute 'name']
Traceback (most recent call last):
  File "C:\workspace\codes\edit\JMComic-Crawler-Python\src\jmcomic\jm_option.py", line 561, in call_all_plugin
    self.invoke_plugin(pclass, kwargs, extra, pinfo)
  File "C:\workspace\codes\edit\JMComic-Crawler-Python\src\jmcomic\jm_option.py", line 604, in invoke_plugin
    self.handle_plugin_unexpected_error(e, pinfo, kwargs, plugin, pclass)
  File "C:\workspace\codes\edit\JMComic-Crawler-Python\src\jmcomic\jm_option.py", line 634, in handle_plugin_unexpected_error
    raise e
  File "C:\workspace\codes\edit\JMComic-Crawler-Python\src\jmcomic\jm_option.py", line 592, in invoke_plugin
    plugin.invoke(**kwargs)
  File "C:\workspace\codes\edit\JMComic-Crawler-Python\src\jmcomic\jm_plugin.py", line 304, in invoke
    zip_path = self.get_zip_path(album, None, filename_rule, suffix, zip_dir)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\workspace\codes\edit\JMComic-Crawler-Python\src\jmcomic\jm_plugin.py", line 398, in get_zip_path
    filename = DirRule.apply_rule_directly(album, photo, filename_rule)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\workspace\codes\edit\JMComic-Crawler-Python\src\jmcomic\jm_option.py", line 184, in apply_rule_directly
    return cls.apply_rule_solver(album, photo, cls.get_rule_solver(rule))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\workspace\codes\edit\JMComic-Crawler-Python\src\jmcomic\jm_option.py", line 180, in apply_rule_solver
    return func(detail)
           ^^^^^^^^^^^^
  File "C:\workspace\codes\edit\JMComic-Crawler-Python\src\jmcomic\jm_option.py", line 152, in solve_func
    return fix_windir_name(str(DetailEntity.get_dirname(detail, rule[1:])))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\workspace\codes\edit\JMComic-Crawler-Python\src\jmcomic\jm_entity.py", line 164, in get_dirname
    return getattr(detail, ref)
           ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'name'

配置如下:

plugins:
  after_album:
    - plugin: zip # 压缩文件插件
      kwargs:
        level: album # 按照章节,一个章节一个压缩文件
        filename_rule: Pname # 压缩文件的命名规则
        zip_dir: xxxxxx # 压缩文件存放的文件夹
        delete_original_file: true # 压缩成功后,删除所有原文件和文件夹
bestsort commented 2 months ago
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\workspace\codes\edit\JMComic-Crawler-Python\src\jmcomic\jm_entity.py", line 164, in get_dirname
    return getattr(detail, ref)
           ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'title'

此处的Pname替换成Ptitle会出现同样的错误

plugins:
  after_album:
    - plugin: zip # 压缩文件插件
      kwargs:
        level: album # 按照章节,一个章节一个压缩文件
        filename_rule: Ptitle # 压缩文件的命名规则
        zip_dir: xxxxxx # 压缩文件存放的文件夹
        delete_original_file: true # 压缩成功后,删除所有原文件和文件夹
hect0x7 commented 2 months ago

此处如果使用 level: album,filename_rule只能指定Axxx,这算是一个限制。 因为一个本子可能有很多章节,但是整个本子压缩到一个文件,因此不能用章节属性来命名,只能用本子属性来命名。

文档里忘记特别注明了,下次补上 所以解决方案:

plugins:
  after_album:
    - plugin: zip
      kwargs:
        level: album
        filename_rule: Atitle # 压缩文件的命名:本子标题
        zip_dir: xxxxxx
        delete_original_file: true