Skip to content

Commit 43427b5

Browse files
committed
fix
1 parent 3dbc68d commit 43427b5

File tree

1 file changed

+32
-21
lines changed

1 file changed

+32
-21
lines changed

scripts/ggdrive_downloadVideo.js

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -145,32 +145,43 @@ export const shared = {
145145
}
146146

147147
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+
);
151156

152-
let text = await res.text();
153-
let json = parse(text);
157+
let text = await res.text();
158+
let json = parse(text);
154159

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+
}
158165

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+
);
162169

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+
}
172182

173-
return result;
183+
if (lastError) throw lastError;
184+
return null;
174185
}
175186

176187
return await getLink(docid);

0 commit comments

Comments
 (0)