@@ -11,7 +11,7 @@ import * as cheerio from "npm:cheerio"; // FOR DENO
11
11
import * as cheerio from "cheerio" ;
12
12
import { decrypt } from "./helpers/decoder" ;
13
13
14
- const BASEDOM = "https://whisperingauroras.com" ;
14
+ let BASEDOM = "https://whisperingauroras.com" ;
15
15
16
16
interface Servers {
17
17
name : string | null ;
@@ -22,37 +22,44 @@ interface APIResponse {
22
22
image : string | null ;
23
23
mediaId : string | null ;
24
24
stream : string | null ;
25
+ referer : string ;
25
26
}
26
27
interface RCPResponse {
27
28
metadata : {
28
- title : string ;
29
29
image : string ;
30
30
} ;
31
31
data : string ;
32
32
}
33
- async function serversLoad ( html : string ) : Promise < Servers [ ] > {
33
+ async function serversLoad ( html : string ) : Promise < { servers : Servers [ ] ; title : string } > {
34
34
const $ = cheerio . load ( html ) ;
35
35
const servers : Servers [ ] = [ ] ;
36
+ const title = $ ( "title" ) . text ( ) ?? "" ;
37
+ const base = $ ( "iframe" ) . attr ( "src" ) ?? "" ;
38
+ BASEDOM = new URL ( base . startsWith ( "//" ) ? "https:" + base : base ) . origin ?? BASEDOM ;
36
39
$ ( ".serversList .server" ) . each ( ( index , element ) => {
37
40
const server = $ ( element ) ;
38
41
servers . push ( {
39
42
name : server . text ( ) . trim ( ) ,
40
43
dataHash : server . attr ( "data-hash" ) ?? null ,
41
44
} ) ;
42
45
} ) ;
43
- return servers ;
46
+ return {
47
+ servers : servers ,
48
+ title : title ,
49
+ } ;
44
50
}
45
51
async function SRCRCPhandler ( ) {
46
52
}
47
53
async function PRORCPhandler ( prorcp : string ) : Promise < string | null > {
48
54
const prorcpFetch = await fetch ( `${ BASEDOM } /prorcp/${ prorcp } ` ) ;
49
55
const prorcpResponse = await prorcpFetch . text ( ) ;
50
- const jsFile =
51
- prorcpResponse . match ( / < s c r i p t \s + s r c = " \/ ( [ ^ " ] * \. j s ) \? \_ = ( [ ^ " ] * ) " > < \/ s c r i p t > / gm) ?. reduce ( ( _ , match ) =>
52
- match . replace ( / .* s r c = " \/ ( [ ^ " ] * \. j s ) \? \_ = ( [ ^ " ] * ) " .* / , "$1?_=$2" )
53
- ) || "" ;
56
+
57
+ const scripts = prorcpResponse . match ( / < s c r i p t \s + s r c = " \/ ( [ ^ " ] * \. j s ) \? \_ = ( [ ^ " ] * ) " > < \/ s c r i p t > / gm) ;
58
+ const script = ( scripts ?. [ scripts . length - 1 ] . includes ( "cpt.js" ) )
59
+ ? scripts ?. [ scripts . length - 2 ] . replace ( / .* s r c = " \/ ( [ ^ " ] * \. j s ) \? \_ = ( [ ^ " ] * ) " .* / , "$1?_=$2" )
60
+ : scripts ?. [ scripts . length - 1 ] . replace ( / .* s r c = " \/ ( [ ^ " ] * \. j s ) \? \_ = ( [ ^ " ] * ) " .* / , "$1?_=$2" ) ;
54
61
const jsFileReq = await fetch (
55
- `${ BASEDOM } /${ jsFile } ` ,
62
+ `${ BASEDOM } /${ script } ` ,
56
63
{
57
64
"headers" : {
58
65
"accept" : "*/*" ,
@@ -89,7 +96,6 @@ async function rcpGrabber(html: string): Promise<RCPResponse | null> {
89
96
if ( ! match ) return null ;
90
97
return {
91
98
metadata : {
92
- title : "" ,
93
99
image : "" ,
94
100
} ,
95
101
data : match [ 1 ] ,
@@ -99,13 +105,14 @@ async function tmdbScrape(tmdbId: string, type: "movie" | "tv", season?: number,
99
105
if ( season && episode && ( type === "movie" ) ) {
100
106
throw new Error ( "Invalid Data." ) ;
101
107
}
102
- const url = ( type === ' movie' )
103
- ? `https://vidsrc.net/embed/${ type } ?tmdb=${ tmdbId } `
104
- : `https://vidsrc.net/embed/${ type } ?tmdb=${ tmdbId } &season=${ season } &episode=${ episode } `
108
+ const url = ( type === " movie" )
109
+ ? `https://vidsrc.net/embed/${ type } ?tmdb=${ tmdbId } `
110
+ : `https://vidsrc.net/embed/${ type } ?tmdb=${ tmdbId } &season=${ season } &episode=${ episode } ` ;
105
111
const embed = await fetch ( url ) ;
106
112
const embedResp = await embed . text ( ) ;
107
113
108
- const servers = await serversLoad ( embedResp ) ;
114
+ // get some metadata
115
+ const { servers, title } = await serversLoad ( embedResp ) ;
109
116
110
117
const rcpFetchPromises = servers . map ( element => {
111
118
return fetch ( `${ BASEDOM } /rcp/${ element . dataHash } ` ) ;
@@ -122,23 +129,15 @@ async function tmdbScrape(tmdbId: string, type: "movie" | "tv", season?: number,
122
129
switch ( item . data . substring ( 0 , 8 ) ) {
123
130
case "/prorcp/" :
124
131
apiResponse . push ( {
125
- name : item . metadata . title ,
132
+ name : title ,
126
133
image : item . metadata . image ,
127
134
mediaId : tmdbId ,
128
135
stream : await PRORCPhandler ( item . data . replace ( "/prorcp/" , "" ) ) ,
136
+ referer : BASEDOM ,
129
137
} ) ;
130
138
break ;
131
- // 2embed sometimes stops working...(fix later)
132
- // case "///srcrc":
133
- // apiResponse.push({
134
- // name: item.metadata.title,
135
- // image: item.metadata.image,
136
- // mediaId: tmdbId,
137
- // stream: item.data,
138
- // });
139
139
}
140
140
}
141
- return ( apiResponse ) ;
141
+ return apiResponse ;
142
142
}
143
-
144
143
export default tmdbScrape ;
0 commit comments