@@ -4,6 +4,7 @@ import cache from '@/utils/cache';
4
4
import ofetch from '@/utils/ofetch' ;
5
5
import * as cheerio from 'cheerio' ;
6
6
import { parseDate } from '@/utils/parse-date' ;
7
+ import timezone from '@/utils/timezone' ;
7
8
import path from 'node:path' ;
8
9
import { art } from '@/utils/render' ;
9
10
import CryptoJS from 'crypto-js' ;
@@ -47,13 +48,20 @@ function decryptImageUrl(cipherText) {
47
48
return cipher . toString ( CryptoJS . enc . Utf8 ) ;
48
49
}
49
50
51
+ function createAuthToken ( ) {
52
+ const t = Date . now ( ) ;
53
+ const e = 't' + t ;
54
+ return 'v1' + t + CryptoJS . HmacSHA1 ( e , '439642a904ef43d092d45509cdc4391c' ) . toString ( ) ;
55
+ }
56
+
50
57
function fetchArticle ( item ) {
51
58
return cache . tryGet ( item . link , async ( ) => {
52
59
const response = await ofetch ( item . link ) ;
53
60
const $ = cheerio . load ( response ) ;
54
61
55
62
$ ( '.original-title, .lookall-box' ) . remove ( ) ;
56
63
item . author = item . author || $ ( 'span[data-role="original-link"] a' ) . text ( ) ;
64
+ item . pubDate = timezone ( parseDate ( $ ( 'meta[itemprop="dateUpdate"]' ) . attr ( 'content' ) ) , 8 ) ;
57
65
58
66
if ( / w i n d o w \. s o h u _ m p \. a r t i c l e _ v i d e o / . test ( $ ( 'script' ) . text ( ) ) ) {
59
67
const videoSrc = $ ( 'script' )
@@ -128,6 +136,8 @@ async function handler(ctx) {
128
136
. match ( / ( { .* } ) / ) ?. [ 1 ]
129
137
) ;
130
138
const renderData = blockRenderData [ Object . keys ( blockRenderData ) . find ( ( e ) => e . startsWith ( 'FeedSlideloadAuthor' ) ) ] ;
139
+ const briefIntroductionCard = blockRenderData [ Object . keys ( blockRenderData ) . find ( ( e ) => e . startsWith ( 'BriefIntroductionCard' ) ) ] . param . data . list [ 0 ] ;
140
+
131
141
const globalConst = JSON . parse (
132
142
$ ( 'script:contains("globalConst")' )
133
143
. text ( )
@@ -153,7 +163,7 @@ async function handler(ctx) {
153
163
} ,
154
164
body : {
155
165
pvId : CBDRenderConst . COMMONCONFIG . pvId || `${ Date . now ( ) } _${ randomString ( 7 ) } ` ,
156
- pageId : `${ Date . now ( ) } _${ defaultSUV . slice ( 0 , - 5 ) } _${ randomString ( 3 ) } ` ,
166
+ pageId : `${ Date . now ( ) } _${ defaultSUV ? .slice ( 0 , - 5 ) } _${ randomString ( 3 ) } ` ,
157
167
mainContent : {
158
168
productType : contentData . businessType || '13' ,
159
169
productId : contentData . id || '324' ,
@@ -174,34 +184,35 @@ async function handler(ctx) {
174
184
size : 20 ,
175
185
pro : renderData . param . pro || '0,1,3,4,5' ,
176
186
feedType : renderData . param . feedType || 'XTOPIC_SYNTHETICAL' ,
177
- view : '' ,
187
+ view : 'operateFeedMode ' ,
178
188
innerTag : renderData . param . data2 . reqParam . content . innerTag || 'work' ,
179
189
spm : renderData . param . data2 . reqParam . content . spm || 'smpc.channel_248.block3_308_hHsK47_2_fd' ,
180
190
page : 1 ,
181
- requestId : `${ Date . now ( ) } _ ${ randomString ( 13 ) } _${ contentData . id } ` ,
191
+ requestId : `${ Date . now ( ) } ${ randomString ( 7 ) } _${ contentData . id } ` ,
182
192
} ,
183
193
adInfo : { } ,
184
194
context : {
185
195
mkey : globalConst . mkeyConst_mkey , // legacy ID
186
196
} ,
187
197
} ,
188
198
] ,
199
+ asId : createAuthToken ( ) ,
189
200
} ,
190
201
} ) ;
191
202
192
203
const list = blockData . data [ renderData . param . data2 . reqParam . tplCompKey ] . list . map ( ( item ) => ( {
193
204
title : item . title ,
194
205
description : item . brief ,
195
- link : `https://www.sohu.com/a/${ item . id } _${ item . authorId } ` ,
196
- author : item . authorName ,
197
- pubDate : parseDate ( item . postTime , 'x' ) ,
206
+ link : `https://www.sohu.com/a/${ item . id } _${ globalConst . mkeyConst_mkey } ` ,
198
207
} ) ) ;
199
208
200
209
const items = await Promise . all ( list . map ( ( e ) => fetchArticle ( e ) ) ) ;
201
210
202
211
return {
203
212
title : `搜狐号 - ${ globalConst . title } ` ,
213
+ description : briefIntroductionCard . column_9_text ,
204
214
link : originalRequest . url ,
215
+ image : `https:${ briefIntroductionCard . column_2_image } ` ,
205
216
item : items ,
206
217
} ;
207
218
}
0 commit comments