(docid)
| 145 | } |
| 146 | |
| 147 | async function getLink(docid) { |
| 148 | let lastError; |
| 149 | for (let u of ["", 0, 1, 2]) { |
| 150 | let res = await fetch( |
| 151 | "https://drive.google.com/" + |
| 152 | (u !== "" ? `u/${u}/` : "") + |
| 153 | "get_video_info?docid=" + |
| 154 | docid |
| 155 | ); |
| 156 | |
| 157 | let text = await res.text(); |
| 158 | let json = parse(text); |
| 159 | |
| 160 | if (json?.status === "fail") { |
| 161 | lastError = "FAILED: " + json.reason; |
| 162 | console.log(u, docid, lastError); |
| 163 | continue; |
| 164 | } |
| 165 | |
| 166 | json.url_encoded_fmt_stream_map = parseStream( |
| 167 | json.url_encoded_fmt_stream_map |
| 168 | ); |
| 169 | |
| 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 | } |
| 182 | |
| 183 | if (lastError) throw new Error(lastError); |
| 184 | return null; |
| 185 | } |
| 186 | |
| 187 | return await getLink(docid); |
| 188 | }, |
no test coverage detected