@@ -99,7 +99,7 @@ export const route: Route = {
9999 } ,
100100 radar : [
101101 {
102- source : [ 'patreon.com/:creator' ] ,
102+ source : [ 'patreon.com/:creator' , 'www.patreon.com/cw/:creator' ] ,
103103 } ,
104104 ] ,
105105 name : 'Home' ,
@@ -117,6 +117,24 @@ async function handler(ctx) {
117117 const response = await ofetch ( link ) ;
118118
119119 const $ = cheerio . load ( response ) ;
120+
121+ const ogUrl = $ ( 'meta[property="og:url"]' ) . attr ( 'content' ) ;
122+ if ( ogUrl ?. startsWith ( `${ baseUrl } /cw/` ) ) {
123+ const ogImage = $ ( 'meta[property="og:image"]' ) . attr ( 'content' ) ;
124+ const creatorId = decodeURIComponent ( ogImage || '' ) . match ( / c a r d - t e a s e r - i m a g e \/ c r e a t o r \/ ( \d + ?) \? / ) ?. [ 1 ] ;
125+ if ( creatorId ) {
126+ return {
127+ id : creatorId ,
128+ attributes : {
129+ name : $ ( 'meta[property="og:title"]' ) . attr ( 'content' ) ,
130+ creation_name : $ ( 'meta[name="description"]' ) . attr ( 'content' ) ,
131+ avatar_photo_url : $ ( 'link[rel="preload"][as="image"]' ) . attr ( 'href' ) || ogImage ,
132+ } ,
133+ } ;
134+ }
135+ throw new Error ( 'Unable to extract creator ID' ) ;
136+ }
137+
120138 const nextData = JSON . parse ( $ ( '#__NEXT_DATA__' ) . text ( ) ) ;
121139 const bootstrapEnvelope = nextData . props . pageProps . bootstrapEnvelope ;
122140
@@ -189,7 +207,11 @@ async function handler(ctx) {
189207 title : creatorData . attributes . name ,
190208 description : creatorData . attributes . creation_name ,
191209 link,
192- image : creatorData . attributes . avatar_photo_url ,
210+ image :
211+ creatorData . attributes . avatar_photo_image_urls ?. thumbnail_large ||
212+ creatorData . attributes . avatar_photo_image_urls ?. thumbnail ||
213+ creatorData . attributes . avatar_photo_image_urls ?. original ||
214+ creatorData . attributes . avatar_photo_url ,
193215 item : items ,
194216 allowEmpty : true ,
195217 } ;
0 commit comments