{"_id":"@abrifq/google-drive-downloader","name":"@abrifq/google-drive-downloader","dist-tags":{"latest":"1.1.0"},"versions":{"1.1.0":{"name":"@abrifq/google-drive-downloader","version":"1.1.0","description":"Get direct download link for a PUBLIC google drive file link. Not tested with folders.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/Abrifq/gdrive-downloader.git"},"keywords":["google","drive","download","link","generator"],"author":{"name":"Arda \"Abrifq\" Aydın","email":"2200656005@nku.edu.tr","url":"https://github.com/Abrifq"},"license":"MIT","bugs":{"url":"https://github.com/Abrifq/gdrive-downloader/issues"},"homepage":"https://github.com/Abrifq/gdrive-downloader#readme","_id":"@abrifq/google-drive-downloader@1.1.0","gitHead":"a2414420fa83c11ac8b686cf3c22efcd25bd9608","_nodeVersion":"21.2.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-1zaYM1q1piX7ZUA6BesyO7dtGIQUfMy3lvFtO2eXUUommZDpdHxBr5CZzEN+SKaJadNchs1mAxf+gufiZy8XTw==","shasum":"1dfc9d296fea92d50999944f5f00fbe72083d30a","tarball":"https://registry.npmjs.org/@abrifq/google-drive-downloader/-/google-drive-downloader-1.1.0.tgz","fileCount":5,"unpackedSize":9308,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDUW6w7BhG6sELjOHBJFj4Kjf4UikrfpdCl/HtnxxMpmAiACx/AJr3KhtZxdDRbdxd1NAcV/V0eQYKczg/yiiXZDkA=="}]},"_npmUser":{"name":"abrifq","email":"melezorus34@gmail.com"},"directories":{},"maintainers":[{"name":"abrifq","email":"melezorus34@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/google-drive-downloader_1.1.0_1700431065505_0.1429559320014011"},"_hasShrinkwrap":false}},"time":{"created":"2023-11-19T21:57:45.409Z","1.1.0":"2023-11-19T21:57:45.663Z","modified":"2023-11-19T21:57:45.942Z"},"maintainers":[{"name":"abrifq","email":"melezorus34@gmail.com"}],"description":"Get direct download link for a PUBLIC google drive file link. Not tested with folders.","homepage":"https://github.com/Abrifq/gdrive-downloader#readme","keywords":["google","drive","download","link","generator"],"repository":{"type":"git","url":"git+https://github.com/Abrifq/gdrive-downloader.git"},"author":{"name":"Arda \"Abrifq\" Aydın","email":"2200656005@nku.edu.tr","url":"https://github.com/Abrifq"},"bugs":{"url":"https://github.com/Abrifq/gdrive-downloader/issues"},"license":"MIT","readme":"# Google Drive Public File Downloader\n\nOpen Google Drive.\nUpload a file.\nRight click the file, make it viewable with anyone with a link, copy the link to your program and *voilà!*\nYou can now use the file stored in Google Drive in your program/site -- with the help of this tiny library!\n\n## Usage\n\nThe library is written both as an ES6 module (`index.mjs`) and a CommonJS module (`index.js`).\n\n```js\nimport gDriveDownloader from \"gdrive-downloader/index.mjs\";\n\nconst links = {\n    catPic: \"https://drive.google.com/file/d/totes_real_cat_link/view?usp=share_link\"\n};\n\ngDriveDownloader(links.catPic)\n.then(fetch)\n.then(rsp=>rsp.blob())\n.then(showDialogWithImgBlob)\n.catch(logger.error);\n```\n\n## Notes\n\n### File Link\n\nMake sure the link passed is **at least viewable** by **anyone with the link**.\nOtherwise Google Drive will just redirect downloading it since the library itself doesn't supply any credentials by default.\n\n### Errors and being outdated\n\n*On the cases the fetch fails, say, due to a network blocking, **the error will escalate**!*\n\n*On the cases the library can't handle the response, the library will return an empty string.*\n\nSince the intended usage is directly feeding it to `fetch` - which throws on invalid urls like empty strings,\nyou can just `catch` at the end of the promise chain.\n\nHowever, if you just `await` it, you can use `if(url.length == 0)` to determine if the fetching has failed.\n\n### How it works\n\nThe library first gets the file ID from the file link, then uses it to make a download *start* link, and uses it to get the **actual** download link.\n\nBy utilizing the [manual redirect mode of fetch](https://fetch.spec.whatwg.org/#concept-request-redirect-mode), the library can see if the download needs a confirmation due to \"virus scan fails\".\n\nIf it passes the scan, Drive redirects us to the file link.\nSince we stop at the first redirect, the developer can choose to download the file later.\n\nIf it fails the scan, the library extracts the confirmation link from the page -- which just redirects you to the file upon requesting it.\n\nIf it fails with an unknown status code due to not existing (404 Not Found) or something else like spam (429 Too Many Requests), the library will just return an empty string and log the file ID and status code to the console.\n","readmeFilename":"README.md"}