@@ -145,32 +145,43 @@ export const shared = {
145
145
}
146
146
147
147
async function getLink ( docid ) {
148
- let res = await fetch (
149
- "https://drive.google.com/get_video_info?docid=" + docid
150
- ) ;
148
+ let lastError ;
149
+ for ( let u of [ "" , 0 , 1 , 2 , 3 , 4 , 5 , 6 ] ) {
150
+ let res = await fetch (
151
+ "https://drive.google.com/" +
152
+ ( u !== "" ? `u/${ u } /` : "" ) +
153
+ "get_video_info?docid=" +
154
+ docid
155
+ ) ;
151
156
152
- let text = await res . text ( ) ;
153
- let json = parse ( text ) ;
157
+ let text = await res . text ( ) ;
158
+ let json = parse ( text ) ;
154
159
155
- if ( json ?. status === "fail" ) {
156
- throw Error ( "FAILED: " + json . reason ) ;
157
- }
160
+ if ( json ?. status === "fail" ) {
161
+ lastError = Error ( "FAILED: " + json . reason ) ;
162
+ console . log ( u , lastError ) ;
163
+ continue ;
164
+ }
158
165
159
- json . url_encoded_fmt_stream_map = parseStream (
160
- json . url_encoded_fmt_stream_map
161
- ) ;
166
+ json . url_encoded_fmt_stream_map = parseStream (
167
+ json . url_encoded_fmt_stream_map
168
+ ) ;
162
169
163
- let result = json . url_encoded_fmt_stream_map . map ( function ( stream ) {
164
- let name = json . title . replace ( / \+ / g, " " ) ;
165
- return {
166
- idfile : docid ,
167
- name : name ,
168
- quality : stream . quality ,
169
- url : stream . url ,
170
- } ;
171
- } ) ;
170
+ let result = json . url_encoded_fmt_stream_map . map ( function ( stream ) {
171
+ let name = json . title . replace ( / \+ / g, " " ) ;
172
+ return {
173
+ idfile : docid ,
174
+ name : name ,
175
+ quality : stream . quality ,
176
+ url : stream . url ,
177
+ } ;
178
+ } ) ;
179
+
180
+ return result ;
181
+ }
172
182
173
- return result ;
183
+ if ( lastError ) throw lastError ;
184
+ return null ;
174
185
}
175
186
176
187
return await getLink ( docid ) ;
0 commit comments