[Python] Colab: Google Drive Folder to JSON
Description
I was thinking to myself the other day: “Wouldn't it be nice if I had a tool that generates a JSON file from a Google Drive folder?”.
And then I Googled it. Only to see pages and pages of different types of implementations appearing. But all of them seemed kind of kludgy (not that this tool is perfect either, but…)
So I did the thing programmers complain about when other programmers do it. I reinvented the wheel. With Colab and Python.
You can generate a JSON file from your Drive folder structure with this Google Colab project.
Example link: https://drive.google.com/drive/folders/120dv78Hzo52KmI92LfQYeibdv60PHYeJ
How to start:
- Make a copy of it (Opening in a new tab is recommended)
- Open the Parameters list
The Iframe below may not work. Prefer opening in a new tab.
How to use it:
- Change folder permission to public
- Copy the folder's ID in the URL
- Add the output folder
- Add the name of the output file
- Click play in 1, 2, 3, 4 and 5 respectively
And you're done.
The output will be something like this:
File Id: 17TwIJhnGNYqeWfWbqxLDp3F2s8Ekgbaq Preview: https://drive.google.com/file/d/17TwIJhnGNYqeWfWbqxLDp3F2s8Ekgbaq/view Direct Link: https://docs.google.com/uc?export=view&id=17TwIJhnGNYqeWfWbqxLDp3F2s8Ekgbaq
Be aware::
It will prompt a Google authentication window, for it to read your Drive
If you update the folder structure, you can rerun the code. It will update the file, keeping the same output link.
Important info:
- You may find a CORS error / crossdomain error, while obtaining this as a REST request. because normal users can't access HTTP parameters. Thus, acknowledge that this method has its limitations. However, all those limitations can be addressed case-by-case.
*The more files you have in the folder, the longer the processing will take to finish.
Example
*May not work due to changes on Google's CORB / CORS policy
If you find it useful, don't use it for piracy. Please.
Bye.

Comentários
Postar um comentário