@@ -1090,59 +1090,96 @@ export const signInApi = (userId: number, dayId: number) => {
10901090
10911091// 获取图片列表,需要通过正则来解析 html 文件内容
10921092export const getComicPicListApi = ( comicId : number , shuntKey : number | undefined ) => {
1093- return http . Get < { list : string [ ] } , string > ( 'chapter_view_template' , {
1094- params : {
1095- id : comicId ,
1096- mode : 'vertical' ,
1097- page : 0 ,
1098- app_img_shunt : shuntKey ,
1099- express : 'off' ,
1100- v : Math . floor ( Date . now ( ) / 1000 ) ,
1101- // id=416130&mode=vertical&page=0&app_img_shunt=1&express=off&v=1727492089
1102- } ,
1103- async transform ( htmlStr ) {
1104- // 2025.06.15 新版匹配方式
1105- // 正则表达式匹配 result 对象
1106- const resultRegex = / c o n s t r e s u l t \s * = \s * ( { [ \s \S ] * ?} ) ; /
1107- const resultMatch = htmlStr . match ( resultRegex )
1108- let result : { images : Array < string > } | null = null
1109- if ( resultMatch ) {
1110- try {
1111- // oxlint-disable-next-line
1112- result = eval ( `(${ resultMatch [ 1 ] } )` )
1113- } catch ( e ) {
1114- console . error ( 'Error parsing result object:' , e )
1093+ return http . Get < { list : string [ ] ; scrambleId : number ; speed : string } , string > (
1094+ 'chapter_view_template' ,
1095+ {
1096+ params : {
1097+ id : comicId ,
1098+ mode : 'vertical' ,
1099+ page : 0 ,
1100+ app_img_shunt : shuntKey ,
1101+ express : 'off' ,
1102+ v : Math . floor ( Date . now ( ) / 1000 ) ,
1103+ // id=416130&mode=vertical&page=0&app_img_shunt=1&express=off&v=1727492089
1104+ } ,
1105+ async transform ( htmlStr ) {
1106+ // 2025.06.15 新版匹配方式
1107+ // 正则表达式匹配 result 对象
1108+ const resultRegex = / c o n s t r e s u l t \s * = \s * ( { [ \s \S ] * ?} ) ; /
1109+ const resultMatch = htmlStr . match ( resultRegex )
1110+ let result : { images : Array < string > } | null = null
1111+ if ( resultMatch ) {
1112+ try {
1113+ // oxlint-disable-next-line
1114+ result = eval ( `(${ resultMatch [ 1 ] } )` )
1115+ } catch ( e ) {
1116+ console . error ( 'Error parsing result object:' , e )
1117+ }
11151118 }
1116- }
11171119
1118- // 正则表达式匹配 config 对象
1119- const configRegex = / c o n s t c o n f i g \s * = \s * ( { [ \s \S ] * ?} ) ; /
1120- const configMatch = htmlStr . match ( configRegex )
1121- let config : {
1122- cache : string
1123- imghost : string
1124- jmid : string
1125- } | null = null
1126- if ( configMatch ) {
1127- try {
1128- // oxlint-disable-next-line
1129- config = eval ( `(${ configMatch [ 1 ] } )` )
1130- } catch ( e ) {
1131- console . error ( 'Error parsing config object:' , e )
1120+ // 正则表达式匹配 config 对象
1121+ const configRegex = / c o n s t c o n f i g \s * = \s * ( { [ \s \S ] * ?} ) ; /
1122+ const configMatch = htmlStr . match ( configRegex )
1123+ let config : {
1124+ cache : string
1125+ imghost : string
1126+ jmid : string
1127+ } | null = null
1128+ if ( configMatch ) {
1129+ try {
1130+ // oxlint-disable-next-line
1131+ config = eval ( `(${ configMatch [ 1 ] } )` )
1132+ } catch ( e ) {
1133+ console . error ( 'Error parsing config object:' , e )
1134+ }
11321135 }
1133- }
1134- if ( ! result || ! config ) {
1135- return {
1136- list : [ ] ,
1136+
1137+ // 2026.03.26
1138+ // 新增 scrambleId 和 speed 参数,用于判断是否需要解密
1139+ // 出现 gif 后缀图片
1140+ // 匹配 scrambleId
1141+ const scrambleIdRegex = / v a r s c r a m b l e _ i d \s * = \s * ( \d + ) ; /
1142+ const scrambleIdMatch = htmlStr . match ( scrambleIdRegex )
1143+ let scrambleId = 0
1144+ if ( scrambleIdMatch ) {
1145+ try {
1146+ scrambleId = Number . parseInt ( scrambleIdMatch [ 1 ] )
1147+ } catch ( e ) {
1148+ console . error ( 'Error parsing scrambleId arg:' , e )
1149+ }
11371150 }
1138- }
1139- return {
1140- list : result . images . map (
1151+
1152+ // 匹配 speed
1153+ const speedRegex = / v a r s p e e d \s * = \s * ' ( .* ) ' ; /
1154+ const speedMatch = htmlStr . match ( speedRegex )
1155+ let speed = ''
1156+ if ( speedMatch ) {
1157+ try {
1158+ speed = speedMatch [ 1 ]
1159+ } catch ( e ) {
1160+ console . error ( 'Error parsing speed arg:' , e )
1161+ }
1162+ }
1163+
1164+ if ( ! result || ! config ) {
1165+ return {
1166+ list : [ ] ,
1167+ scrambleId,
1168+ speed,
1169+ }
1170+ }
1171+ const list = result . images . map (
11411172 ( item ) => `${ config . imghost } /media/photos/${ config . jmid } /${ item } ${ config . cache } ` ,
1142- ) ,
1143- }
1173+ )
1174+ console . log ( 'list' , list )
1175+ return {
1176+ list,
1177+ scrambleId,
1178+ speed,
1179+ }
1180+ } ,
11441181 } ,
1145- } )
1182+ )
11461183 // .then(() => {
11471184 // return [
11481185 // "https://cdn-msp.jmapiproxy3.cc/media/photos/113592/00001.webp",
0 commit comments