@@ -38,7 +38,7 @@ def get_title(self) -> str:
3838 def __len__ (self ):
3939 raise NotImplementedError
4040
41- def __getitem__ (self , item ):
41+ def __getitem__ (self , item ) -> Union [ 'JmAlbumDetail' , 'JmPhotoDetail' ] :
4242 raise NotImplementedError
4343
4444
@@ -99,6 +99,7 @@ def __init__(self,
9999 title ,
100100 keywords ,
101101 series_id ,
102+ sort ,
102103 page_arr = None ,
103104 data_original_domain = None ,
104105 author = None ,
@@ -107,6 +108,7 @@ def __init__(self,
107108 self .photo_id : str = photo_id
108109 self .scramble_id : str = scramble_id
109110 self .title : str = title
111+ self .sort : int = int (sort )
110112 self ._keywords : str = keywords
111113 self ._series_id : int = int (series_id )
112114
@@ -120,8 +122,10 @@ def __init__(self,
120122
121123 # 该photo的所有图片名 img_name
122124 self .page_arr : List [str ] = page_arr
123- self .data_original_domain = data_original_domain
125+ # 图片域名
126+ self .data_original_domain : StrNone = data_original_domain
124127
128+ @property
125129 def is_single_album (self ) -> bool :
126130 return self ._series_id == 0
127131
@@ -131,7 +135,20 @@ def keyword_list(self) -> List[str]:
131135
132136 @property
133137 def album_id (self ) -> str :
134- return self .photo_id if self .is_single_album () else self ._series_id
138+ return self .photo_id if self .is_single_album else self ._series_id
139+
140+ @property
141+ def album_index (self ) -> int :
142+ """
143+ 返回这个章节在本子中的序号,从1开始
144+ """
145+
146+ # 如果是单章本子,JM给的sort为2。
147+ # 这里返回1比较符合语义定义
148+ if self .is_single_album and self .sort == 2 :
149+ return 1
150+
151+ return self .sort
135152
136153 @property
137154 def author (self ) -> str :
@@ -167,7 +184,11 @@ def get_img_data_original(self, img_name: str) -> str:
167184 例如:img_name = 01111.webp
168185 返回:https://cdn-msp2.18comic.org/media/photos/147643/01111.webp
169186 """
170- return f'https://{ self .data_original_domain } /media/photos/{ self .photo_id } /{ img_name } '
187+ data_original_domain = self .data_original_domain
188+ if data_original_domain is None :
189+ raise AssertionError (f'图片域名为空: { self .__dict__ } ' )
190+
191+ return f'https://{ data_original_domain } /media/photos/{ self .photo_id } /{ img_name } '
171192
172193 def __getitem__ (self , item ) -> JmImageDetail :
173194 return self .create_image_detail (item )
@@ -224,6 +245,7 @@ def create_photo_detail(self, index) -> Tuple[JmPhotoDetail, Tuple]:
224245 title = photo_title ,
225246 keywords = '' ,
226247 series_id = self .album_id ,
248+ sort = index + 1 ,
227249 author = self .author ,
228250 from_album = self ,
229251 page_arr = None ,
0 commit comments