(targets)
| 4994 | async getFilesList(dirs, accessToken, processed = 0) { |
| 4995 | let cnt = 0; |
| 4996 | const fetch = async (targets) => { |
| 4997 | let files = []; |
| 4998 | for (let dir of targets) { |
| 4999 | $doc.find(".loading-popup .loading-title").html(`文件获取中`); |
| 5000 | let url = `${config.$baidu.api.getFiles}&dir=${encodeURIComponent(dir.path)}&access_token=${accessToken}`; |
| 5001 | let res = await base.get(url, { "User-Agent": config.$baidu.api.ua.downloadLink }); |
| 5002 | cnt++; |
| 5003 | if (res?.list?.length && (res.errno === 0 || res.errmsg === "succ")) { |
| 5004 | let subFiles = res.list.filter(f => !f.isdir); |
| 5005 | processed += subFiles.length; |
| 5006 | $doc.find(".loading-popup .swal2-html-container").html(`<div>已获取 ${processed} 个文件~</div><div>${dir.path}</div>`); |
| 5007 | files = files.concat(subFiles); |
| 5008 | let subDirs = res.list.filter(f => f.isdir); |
| 5009 | if (subDirs.length > 0) { |
| 5010 | files = files.concat(await fetch(subDirs)); |
| 5011 | } |
| 5012 | } |
| 5013 | if (cnt >= 50) { |
| 5014 | $doc.find(".loading-popup .swal2-html-container").html(`<div>已获取 ${processed} 个文件~</div><div>休息 3 秒...</div>`); |
| 5015 | await base.sleep(3000); |
| 5016 | cnt = 0; |
| 5017 | } |
| 5018 | } |
| 5019 | return files; |
| 5020 | }; |
| 5021 | return await fetch(dirs); |
| 5022 | }, |
| 5023 | async getLink() { |
no outgoing calls
no test coverage detected