@@ -61,6 +61,58 @@ def id(self) -> str:
6161 def title (self ) -> str :
6262 return getattr (self , 'name' )
6363
64+ @property
65+ def author (self ):
66+ raise NotImplementedError
67+
68+ @property
69+ def oname (self ) -> str :
70+ """
71+ oname = original name
72+
73+ 示例:
74+
75+ title:"喂我吃吧 老師! [欶瀾漢化組] [BLVEFO9] たべさせて、せんせい! (ブルーアーカイブ) [中國翻譯] [無修正]"
76+
77+ oname:"喂我吃吧 老師!"
78+
79+ :return: 返回本子的原始名称
80+ """
81+ from .jm_toolkit import JmcomicText
82+ oname = JmcomicText .parse_orig_album_name (self .title )
83+ if oname is not None :
84+ return oname
85+
86+ jm_log ('entity' , f'无法提取出原album名字: { self .title } ' )
87+ return self .title
88+
89+ @property
90+ def authoroname (self ):
91+ """
92+ authoroname = author + oname
93+
94+ 比较好识别的一种本子名称方式
95+
96+ 具体格式: f'【author】{oname}'
97+
98+ 示例:
99+
100+ 原本子名:喂我吃吧 老師! [欶瀾漢化組] [BLVEFO9] たべさせて、せんせい! (ブルーアーカイブ) [中國翻譯] [無修正]
101+
102+ authoroname:【BLVEFO9】喂我吃吧 老師!
103+
104+ :return: 返回作者名+作品原名,格式为: '【author】{oname}'
105+ """
106+ return f'【{ self .author } 】{ self .oname } '
107+
108+ @property
109+ def idoname (self ):
110+ """
111+ 类似 authoroname
112+ :return: '[id] {oname}'
113+ """
114+ return f'[{ self .id } ] { self .oname } '
115+
64116 def __str__ (self ):
65117 return f'{ self .__class__ .__name__ } ({ self .id } -{ self .title } )'
66118
@@ -71,19 +123,33 @@ def __alias__(cls):
71123 cls_name = cls .__name__
72124 return cls_name [cls_name .index ("m" ) + 1 : cls_name .rfind ("Detail" )].lower ()
73125
74- def get_dirname (self , ref : str ) -> str :
126+ @classmethod
127+ def get_dirname (cls , detail : 'DetailEntity' , ref : str ) -> str :
75128 """
76129 该方法被 DirDule 调用,用于生成特定层次的文件夹
130+
77131 通常调用方式如下:
78- Atitle -> ref = 'title' -> album .get_dirname(ref )
79- 该方法需要返回 ref 对应的文件夹名,默认实现直接返回 getattr(self, ref )
132+ Atitle -> ref = 'title' -> DetailEntity .get_dirname(album, 'title' )
133+ 该方法需要返回 ref 对应的文件夹名,默认实现直接返回 getattr(detail, 'title' )
80134
81135 用户可重写此方法,来实现自定义文件夹名
82136
137+ v2.4.5: 此方法支持优先从 JmModuleConfig.XFIELD_ADVICE 中获取自定义函数并调用返回结果
138+
139+ :param detail: 本子/章节 实例
83140 :param ref: 字段名
84141 :returns: 文件夹名
85142 """
86- return getattr (self , ref )
143+
144+ advice_func = (JmModuleConfig .AFIELD_ADVICE
145+ if isinstance (detail , JmAlbumDetail )
146+ else JmModuleConfig .PFIELD_ADVICE
147+ ).get (ref , None )
148+
149+ if advice_func is not None :
150+ return advice_func (detail )
151+
152+ return getattr (detail , ref )
87153
88154
89155class JmImageDetail (JmBaseEntity ):
@@ -110,7 +176,7 @@ def __init__(self,
110176
111177 self .from_photo : Optional [JmPhotoDetail ] = from_photo
112178 self .query_params : StrNone = query_params
113- self .index = index
179+ self .index = index # 从1开始
114180
115181 # temp fields, in order to simplify passing parameter
116182 self .save_path : str = ''
@@ -171,7 +237,7 @@ def tag(self) -> str:
171237 """
172238 this tag is used to print pretty info when logging
173239 """
174- return f'{ self .aid } /{ self .img_file_name } { self .img_file_suffix } [{ self .index + 1 } /{ len (self .from_photo )} ]'
240+ return f'{ self .aid } /{ self .img_file_name } { self .img_file_suffix } [{ self .index } /{ len (self .from_photo )} ]'
175241
176242 @classmethod
177243 def is_image (cls ):
@@ -289,7 +355,7 @@ def create_image_detail(self, index) -> JmImageDetail:
289355 data_original ,
290356 from_photo = self ,
291357 query_params = self .data_original_query_params ,
292- index = index ,
358+ index = index + 1 ,
293359 )
294360
295361 def get_img_data_original (self , img_name : str ) -> str :
0 commit comments