11from jmcomic import *
2+ from jmcomic .cl import get_env , JmcomicUI
23
34# 下方填入你要下载的本子的id,一行一个。
45# 每行的首尾可以有空白字符
1213
1314'''
1415
16+ # 单独下载章节
17+ jm_photos = '''
1518
16- def get_jm_album_ids ():
19+
20+ '''
21+
22+
23+ def get_id_set (env_name ):
1724 aid_set = set ()
1825 for text in [
1926 jm_albums ,
20- (get_env ('JM_ALBUM_IDS' ) or '' ).replace ('-' , '\n ' ),
27+ (get_env (env_name , '' ) ).replace ('-' , '\n ' ),
2128 ]:
2229 aid_set .update (str_to_set (text ))
2330
2431 return aid_set
2532
2633
2734def main ():
28- # 下载漫画
29- download_album (get_jm_album_ids (), option = get_option ())
35+ album_id_set = get_id_set ('JM_ALBUM_IDS' )
36+ photo_id_set = get_id_set ('JM_PHOTO_IDS' )
37+
38+ helper = JmcomicUI ()
39+ helper .album_id_list = list (album_id_set )
40+ helper .photo_id_list = list (photo_id_set )
41+
42+ helper .run (get_option ())
3043
3144
3245def get_option ():
@@ -39,18 +52,14 @@ def get_option():
3952 # 覆盖client实现类,实现把请求错误的html下载到文件,方便GitHub Actions下载查看日志
4053 hook_debug (option )
4154
42- # 启用 client 的缓存
43- client = option .build_jm_client ()
44- client .enable_cache ()
45-
4655 # 登录,如果有配置的话
47- login_if_configured (client )
56+ login_if_configured (option . build_jm_client () )
4857
4958 return option
5059
5160
5261def cover_option_config (option : JmOption ):
53- dir_rule = get_env ('DIR_RULE' )
62+ dir_rule = get_env ('DIR_RULE' , None )
5463 if dir_rule is not None :
5564 the_old = option .dir_rule
5665 the_new = DirRule (dir_rule , base_dir = the_old .base_dir )
@@ -64,16 +73,16 @@ def login_if_configured(client):
6473 # 配置的方式很简单,网页上点一点就可以了
6574 # 具体做法请去看官方教程:https://docs.github.com/en/actions/security-guides/encrypted-secrets
6675 # 萌新注意!!!如果你想 `开源` 你的禁漫帐号,你也可以直接把账号密码写到下面的代码😅
67- username = get_env ('JM_USERNAME' )
68- password = get_env ('JM_PASSWORD' )
76+ username = get_env ('JM_USERNAME' , None )
77+ password = get_env ('JM_PASSWORD' , None )
6978 if username is not None and password is not None :
7079 client .login (username , password , True )
7180 print_eye_catching (f'登录禁漫成功' )
7281
7382
7483# noinspection PyUnusedLocal
7584def hook_debug (option ):
76- jm_download_dir = get_env ('JM_DOWNLOAD_DIR' ) or workspace ()
85+ jm_download_dir = get_env ('JM_DOWNLOAD_DIR' , workspace () )
7786 mkdir_if_not_exists (jm_download_dir )
7887
7988 class RaiseErrorAwareClient (JmHtmlClient ):
@@ -91,15 +100,5 @@ def raise_request_error(cls, resp, msg=None):
91100 JmModuleConfig .CLASS_CLIENT_IMPL ['html' ] = RaiseErrorAwareClient
92101
93102
94- def get_env (name ):
95- import os
96- value = os .getenv (name , None )
97-
98- if value is None or value == '' :
99- return None
100-
101- return value
102-
103-
104103if __name__ == '__main__' :
105104 main ()
0 commit comments