Package: ggdrive
ggdriveA command-line script for Google Drive, for downloading and uploading files directly from the terminal.Pre-requisitesInstallationUsagePre-requisitesImportant note: This project requires Google API credentials. That credential file enables the use of Google APIs by this application, and allows the user to login and allow (or deny) the application to access the user's Google Drive files. At this moment, we're not providing the credentials.json needed for this to work, so if you want to use this code, you need to go toGoogle's Developer Console, create a project, and create the OAuth credentials for it, allowing for scopes "drive" and "drive.metadata". You can download the credentials.json and use it here.After downloading yourcredentials.json, go to to your home folder, create a directory called.gdrive, and put yourcredentials.jsonfile in there.The first time you're executing this, a Google page will open and ask for your account, so it can integrate with your Google Drive account, and then it will ask if you give permission to the app. Once you agree, you're all set.InstallationInstall through pip (recommended)python3-mpipinstallggdriveThat's it! You can advance toUsage... Or install manuallyThis project requires:Python 3.6 or greater.Google Client Library1. Clone this repositorygitclonegit@github.com:DiscordTime/ggdrive.gitorgitclonehttps://github.com/DiscordTime/ggdrive.git2. Install dependenciesWe created arequirements.txtwhere you can execute the following to install the needed libs:pipinstall--upgrade-rrequirements.txtorpython3-mpipinstall--upgrade-rrequirements.txt3. If the script gdrive doesn't have execution permission, give it to it.chmod+xgdrive4. Add to PATH environment variable (optional, recommended)You can add this repo folder to you path, so you can execute gdrive from anywhere on your terminal. Open your.bashrcor similar and add one of the following options:exportPATH=$PATH:'<path-to-repo-folder>'oraliasgdrive='<path-to-repo-folder>/gdriveUsageAvailable functions:1. Uploadgdriveupload--helpgdriveupload<file-to-upload>2. Downloadgdrivedownload--helpYou can download a file passing either theid, or thenameof your filegdrivedownload<(fileId/filename)-to-download>To explicitly download via theid, use one of the following:gdrivedownload-i<id-of-file-to-download>
gdrivedownload--id<id-of-file-to-download>To download a file via its name, use one of the following:gdrivedownload-n<name-of-file-to-download>
gdrivedownload--name<name-of-file-to-download>If you're sure that the file that you want to download is the last one that was modified, just use one of the following:gdrivedownload-l
gdrivedownload--lastIf the file is a compressed one, you can try extracting it as soon as it finished downloading by using theextractoption (This option is to be used in combination with one of the above):gdrivedownload-le
gdrivedownload-ei<id-of-file-to-download>
gdrivedownload-en<name-of-file-to-download>
gdrivedownload--last--extractNOTETheextractfunction needs some extra programs to execute. We implement a mechanism that tries to guess the extension of the file you're downloading and use the program you define to extract it. So, the first time you try to download a file of a certain type, when it's time to extract the file, our program will ask you which program you want to choose. After that, if you download a file with this same extension, it will extract it automatically (if you added the--extractoption).Those configurations are located with your other files that we need in the.gdrivein yourHOMEdirectory. The file is calleddata_config.jsonSample{"configs":[{"ext":"application/x-tar","encoding":"gzip","prog":"tar","attrs":"xzvf"},{"ext":null,"encoding":"gzip","prog":"gunzip","attrs":null},{"ext":"application/x-tar","encoding":null,"prog":"tar","attrs":"xvf"}]}3. Listgdrivelistgdrivelist--help