Skip to content

Commit

Permalink
fix typo, format code
Browse files Browse the repository at this point in the history
  • Loading branch information
hect0x7 committed Nov 15, 2023
1 parent e0d643d commit c5895d2
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 32 deletions.
10 changes: 5 additions & 5 deletions src/jmcomic/cl.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ def main(self):
self.parse_arg()
from .api import jm_log
jm_log('command_line',
f'start downloading...\n'
f'- using option: [{self.option_path or "default"}]\n'
f'to be downloaded: \n'
f'- album: {self.album_id_list}\n'
f'- photo: {self.photo_id_list}')
f'start downloading...\n'
f'- using option: [{self.option_path or "default"}]\n'
f'to be downloaded: \n'
f'- album: {self.album_id_list}\n'
f'- photo: {self.photo_id_list}')

from .api import create_option, JmOption
if self.option_path is not None:
Expand Down
14 changes: 7 additions & 7 deletions src/jmcomic/jm_client_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ def request_with_retry(self,

if domain_index != 0 or retry_count != 0:
jm_log(f'req.retry',
', '.join([
f'次数: [{retry_count}/{self.retry_times}]',
f'域名: [{domain_index} of {self.domain_list}]',
f'路径: [{url}]',
f'参数: [{kwargs if "login" not in url else "#login_form#"}]'
])
', '.join([
f'次数: [{retry_count}/{self.retry_times}]',
f'域名: [{domain_index} of {self.domain_list}]',
f'路径: [{url}]',
f'参数: [{kwargs if "login" not in url else "#login_form#"}]'
])
)

try:
Expand Down Expand Up @@ -386,7 +386,7 @@ def album_comment(self,
data['forum_subject'] = 1

jm_log('album.comment',
f'{video_id}: [{comment}]' +
f'{video_id}: [{comment}]' +
(f' to ({comment_id})' if comment_id is not None else '')
)

Expand Down
1 change: 0 additions & 1 deletion src/jmcomic/jm_client_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ def json(self, **kwargs) -> Dict:
"""



class JmDetailClient:

def get_album_detail(self, album_id) -> JmAlbumDetail:
Expand Down
28 changes: 14 additions & 14 deletions src/jmcomic/jm_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,41 @@ class DownloadCallback:

def before_album(self, album: JmAlbumDetail):
jm_log('album.before',
f'本子获取成功: [{album.id}], '
f'作者: [{album.author}], '
f'章节数: [{len(album)}], '
f'总页数: [{album.page_count}], '
f'标题: [{album.name}], '
f'关键词: [{album.tags}]'
f'本子获取成功: [{album.id}], '
f'作者: [{album.author}], '
f'章节数: [{len(album)}], '
f'总页数: [{album.page_count}], '
f'标题: [{album.name}], '
f'关键词: [{album.tags}]'
)

def after_album(self, album: JmAlbumDetail):
jm_log('album.after', f'本子下载完成: [{album.id}]')

def before_photo(self, photo: JmPhotoDetail):
jm_log('photo.before',
f'开始下载章节: {photo.id} ({photo.album_id}[{photo.index}/{len(photo.from_album)}]), '
f'标题: [{photo.name}], '
f'图片数为[{len(photo)}]'
f'开始下载章节: {photo.id} ({photo.album_id}[{photo.index}/{len(photo.from_album)}]), '
f'标题: [{photo.name}], '
f'图片数为[{len(photo)}]'
)

def after_photo(self, photo: JmPhotoDetail):
jm_log('photo.after',
f'章节下载完成: [{photo.id}] ({photo.album_id}[{photo.index}/{len(photo.from_album)}])')
f'章节下载完成: [{photo.id}] ({photo.album_id}[{photo.index}/{len(photo.from_album)}])')

def before_image(self, image: JmImageDetail, img_save_path):
if image.is_exists:
jm_log('image.before',
f'图片已存在: {image.tag} ← [{img_save_path}]'
f'图片已存在: {image.tag} ← [{img_save_path}]'
)
else:
jm_log('image.before',
f'图片准备下载: {image.tag}, [{image.img_url}] → [{img_save_path}]'
f'图片准备下载: {image.tag}, [{image.img_url}] → [{img_save_path}]'
)

def after_image(self, image: JmImageDetail, img_save_path):
jm_log('image.after',
f'图片下载完成: {image.tag}, [{image.img_url}] → [{img_save_path}]')
f'图片下载完成: {image.tag}, [{image.img_url}] → [{img_save_path}]')


class JmDownloader(DownloadCallback):
Expand Down Expand Up @@ -196,5 +196,5 @@ def __enter__(self):
def __exit__(self, exc_type, exc_val, exc_tb):
if exc_type is not None:
jm_log('dler.exception',
f'{self.__class__.__name__} Exit with exception: {exc_type, exc_val}'
f'{self.__class__.__name__} Exit with exception: {exc_type, exc_val}'
)
6 changes: 3 additions & 3 deletions src/jmcomic/jm_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(self, rule: str, base_dir=None):
self.rule_dsl = rule
self.solver_list = self.get_role_solver_list(rule, base_dir)

def deside_image_save_dir(self,
def decide_image_save_dir(self,
album: JmAlbumDetail,
photo: JmPhotoDetail,
) -> str:
Expand Down Expand Up @@ -205,7 +205,7 @@ def decide_photo_batch_count(self, album: JmAlbumDetail):

def decide_image_save_dir(self, photo) -> str:
# 使用 self.dir_rule 决定 save_dir
save_dir = self.dir_rule.deside_image_save_dir(
save_dir = self.dir_rule.decide_image_save_dir(
photo.from_album,
photo
)
Expand Down Expand Up @@ -566,7 +566,7 @@ def handle_plugin_valid_exception(self, e, pinfo: dict, kwargs: dict, plugin):
if mode == 'log':
# log
jm_log('plugin.validation',
f'插件 [{e.plugin.plugin_key}] 参数校验异常:{e.msg}'
f'插件 [{e.plugin.plugin_key}] 参数校验异常:{e.msg}'
)
return

Expand Down
2 changes: 1 addition & 1 deletion src/jmcomic/jm_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def invoke(self,
def apply_filter_then_decide_cache(image: JmImageDetail):
if image.img_file_suffix not in allowed_suffix_set:
self.log(f'跳过下载图片: {image.tag},'
f'因为其后缀\'{image.img_file_suffix}\'不在允许的后缀集合{allowed_suffix_set}内')
f'因为其后缀\'{image.img_file_suffix}\'不在允许的后缀集合{allowed_suffix_set}内')
# hook is_exists True to skip download
image.is_exists = True
return True
Expand Down
2 changes: 1 addition & 1 deletion tests/test_jmcomic/test_jm_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def pname(self):
base_dir: str = workspace()
dir_rule = DirRule('Bd_Aaname_Ppname', base_dir)
# noinspection PyTypeChecker
save_dir = dir_rule.deside_image_save_dir(
save_dir = dir_rule.decide_image_save_dir(
MyAlbum('1', '0', '0', [], *['0'] * 10),
MyPhoto('2', *['0'] * 7)
)
Expand Down

0 comments on commit c5895d2

Please sign in to comment.