v2.4.5: 修正搜索页面的tag标签的正则表达式,增加自动关闭无意义PR的工作流 (#170)

This commit is contained in:
hect0x7 2023-11-30 01:13:18 +08:00 committed by GitHub
parent 6ab7456f99
commit 7bcc28f97d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 77 additions and 21 deletions

30
.github/workflows/close_specific_pr.yml vendored Normal file
View 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 }}

View File

@ -93,11 +93,13 @@ $ jmcomic 422866
* config存放配置文件
* docs项目文档
* src存放源代码
* jmcomic`jmcomic`模块
* tests测试目录存放测试代码使用unittest
* usage用法目录存放示例/使用代码
* tests测试目录存放测试代码使用unittest
* usage用法目录存放示例/使用代码
## 感谢以下项目

View File

@ -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 *

View File

@ -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):

View File

@ -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,
)

View File

@ -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>')