mirror of
https://github.com/hect0x7/JMComic-Crawler-Python.git
synced 2025-09-26 22:31:30 +08:00
v2.4.5: 修正搜索页面的tag标签的正则表达式,增加自动关闭无意义PR的工作流 (#170)
This commit is contained in:
parent
6ab7456f99
commit
7bcc28f97d
30
.github/workflows/close_specific_pr.yml
vendored
Normal file
30
.github/workflows/close_specific_pr.yml
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
name: Close specific PR
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'usage/workflow_download.py'
|
||||
types: [opened, ]
|
||||
|
||||
jobs:
|
||||
close_pr:
|
||||
env:
|
||||
comment: |
|
||||
To prevent beginners from mistakenly submitting PRs,
|
||||
if your PR only modifies the usage/workflow_download.py file,
|
||||
it will be automatically closed.
|
||||
If you really want to submit a PR, please reopen it yourself.
|
||||
Make sure you know what you are doing!
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Close PR
|
||||
run: |
|
||||
PR_TITLE=$(jq -r ".pull_request.title" $GITHUB_EVENT_PATH)
|
||||
echo "PR_TITLE: $PR_TITLE"
|
||||
gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --body '${{ env.comment }}'
|
||||
gh pr close ${{ github.event.pull_request.number }} --repo ${{ github.repository }}
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
@ -93,11 +93,13 @@ $ jmcomic 422866
|
||||
|
||||
* config:存放配置文件
|
||||
* docs:项目文档
|
||||
|
||||
* src:存放源代码
|
||||
|
||||
* jmcomic:`jmcomic`模块
|
||||
* tests:测试目录,存放测试代码,使用unittest
|
||||
* usage:用法目录,存放示例/使用代码
|
||||
|
||||
* tests:测试目录,存放测试代码,使用unittest
|
||||
* usage:用法目录,存放示例/使用代码
|
||||
|
||||
## 感谢以下项目
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
# 被依赖方 <--- 使用方
|
||||
# config <--- entity <--- toolkit <--- client <--- option <--- downloader
|
||||
|
||||
__version__ = '2.4.4'
|
||||
__version__ = '2.4.5'
|
||||
|
||||
from .api import *
|
||||
from .jm_plugin import *
|
||||
|
@ -5,7 +5,7 @@ from .jm_config import *
|
||||
|
||||
class JmBaseEntity:
|
||||
|
||||
def save_to_file(self, filepath):
|
||||
def to_file(self, filepath):
|
||||
from common import PackerUtil
|
||||
PackerUtil.pack(self, filepath)
|
||||
|
||||
@ -21,6 +21,10 @@ class JmBaseEntity:
|
||||
def is_album(cls):
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def is_page(cls):
|
||||
return False
|
||||
|
||||
|
||||
class IndexedEntity:
|
||||
def getindex(self, index: int):
|
||||
@ -508,6 +512,10 @@ class JmPageContent(JmBaseEntity, IndexedEntity):
|
||||
def getindex(self, index: int):
|
||||
return self.content[index]
|
||||
|
||||
@classmethod
|
||||
def is_page(cls):
|
||||
return True
|
||||
|
||||
|
||||
class JmSearchPage(JmPageContent):
|
||||
|
||||
|
@ -176,8 +176,6 @@ class JmOption:
|
||||
plugins: Dict,
|
||||
filepath=None,
|
||||
):
|
||||
# 版本号
|
||||
self.version = JmModuleConfig.JM_OPTION_VER
|
||||
# 路径规则配置
|
||||
self.dir_rule = DirRule(**dir_rule)
|
||||
# 客户端配置
|
||||
@ -203,16 +201,6 @@ class JmOption:
|
||||
def decide_photo_batch_count(self, album: JmAlbumDetail):
|
||||
return self.download.threading.photo
|
||||
|
||||
def decide_image_save_dir(self, photo) -> str:
|
||||
# 使用 self.dir_rule 决定 save_dir
|
||||
save_dir = self.dir_rule.decide_image_save_dir(
|
||||
photo.from_album,
|
||||
photo
|
||||
)
|
||||
|
||||
mkdir_if_not_exists(save_dir)
|
||||
return save_dir
|
||||
|
||||
def decide_album_dir(self, album: JmAlbumDetail) -> str:
|
||||
"""
|
||||
该方法目前仅在 plugin-zip 中使用,不建议外部调用
|
||||
@ -234,7 +222,18 @@ class JmOption:
|
||||
from os.path import join
|
||||
return join(*dir_layer)
|
||||
|
||||
def decide_image_suffix(self, image: JmImageDetail):
|
||||
# noinspection PyMethodMayBeStatic
|
||||
def decide_image_filename(self, image: JmImageDetail) -> str:
|
||||
"""
|
||||
返回图片的文件名,不包含后缀
|
||||
默认返回禁漫的图片文件名,例如:00001 (.jpg)
|
||||
"""
|
||||
return image.filename_without_suffix
|
||||
|
||||
def decide_image_suffix(self, image: JmImageDetail) -> str:
|
||||
"""
|
||||
返回图片的后缀,如果返回的后缀和原后缀不一致,则会进行图片格式转换
|
||||
"""
|
||||
# 动图则使用原后缀
|
||||
if image.is_gif:
|
||||
return image.img_file_suffix
|
||||
@ -242,11 +241,21 @@ class JmOption:
|
||||
# 非动图,以配置为先
|
||||
return self.download.image.suffix or image.img_file_suffix
|
||||
|
||||
def decide_image_save_dir(self, photo) -> str:
|
||||
# 使用 self.dir_rule 决定 save_dir
|
||||
save_dir = self.dir_rule.decide_image_save_dir(
|
||||
photo.from_album,
|
||||
photo
|
||||
)
|
||||
|
||||
mkdir_if_not_exists(save_dir)
|
||||
return save_dir
|
||||
|
||||
def decide_image_filepath(self, image: JmImageDetail, consider_custom_suffix=True) -> str:
|
||||
# 通过拼接生成绝对路径
|
||||
save_dir = self.decide_image_save_dir(image.from_photo)
|
||||
suffix = self.decide_image_suffix(image) if consider_custom_suffix else image.img_file_suffix
|
||||
return os.path.join(save_dir, image.filename_without_suffix + suffix)
|
||||
return os.path.join(save_dir, self.decide_image_filename(image) + suffix)
|
||||
|
||||
def decide_download_cache(self, _image: JmImageDetail) -> bool:
|
||||
return self.download.cache
|
||||
@ -322,7 +331,7 @@ class JmOption:
|
||||
|
||||
def deconstruct(self) -> Dict:
|
||||
return {
|
||||
'version': self.version,
|
||||
'version': JmModuleConfig.JM_OPTION_VER,
|
||||
'log': JmModuleConfig.flag_enable_jm_log,
|
||||
'dir_rule': {
|
||||
'rule': self.dir_rule.rule_dsl,
|
||||
@ -415,7 +424,7 @@ class JmOption:
|
||||
|
||||
client: AbstractJmClient = clazz(
|
||||
postman=postman,
|
||||
domain_list=decide_domain(),
|
||||
domain_list=domain,
|
||||
retry_times=retry_times,
|
||||
)
|
||||
|
||||
|
@ -187,6 +187,13 @@ class JmcomicText:
|
||||
|
||||
return f'{JmModuleConfig.PROT}{domain}{path}'
|
||||
|
||||
@classmethod
|
||||
def format_album_url(cls, aid, domain='18comic.vip'):
|
||||
"""
|
||||
把album_id变为可访问的URL,方便print打印后用浏览器访问
|
||||
"""
|
||||
return cls.format_url(f'/album/{aid}/', domain)
|
||||
|
||||
class DSLReplacer:
|
||||
|
||||
def __init__(self):
|
||||
@ -271,7 +278,7 @@ class JmPageTool:
|
||||
)
|
||||
|
||||
# 用来查找tag列表
|
||||
pattern_html_search_tag_list = compile(r'<a href=".*?">(.*?)</a>')
|
||||
pattern_html_search_tag_list = compile(r'<a[^>]*?>(.*?)</a>')
|
||||
|
||||
# 查找错误,例如 [错误,關鍵字過短,請至少輸入兩個字以上。]
|
||||
pattern_html_search_error = compile(r'<fieldset>\n<legend>(.*?)</legend>\n<div class=.*?>\n(.*?)\n</div>\n</fieldset>')
|
||||
|
Loading…
Reference in New Issue
Block a user