{"id":26784709,"url":"https://github.com/theflash2k/drivesync","last_synced_at":"2025-09-14T20:03:41.245Z","repository":{"id":63168690,"uuid":"405362906","full_name":"TheFlash2k/DriveSync","owner":"TheFlash2k","description":"A Python3 based API to make the usage of Google Drive API for uploading/creating files/folders really easy","archived":false,"fork":false,"pushed_at":"2024-08-15T01:09:29.000Z","size":35,"stargazers_count":2,"open_issues_count":9,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-15T02:26:54.736Z","etag":null,"topics":["google-drive","google-drive-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TheFlash2k.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-11T11:37:43.000Z","updated_at":"2024-08-15T02:26:58.474Z","dependencies_parsed_at":"2024-08-15T02:26:57.626Z","dependency_job_id":"1dc69257-7b28-4c24-884d-7bb052ed6bc7","html_url":"https://github.com/TheFlash2k/DriveSync","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheFlash2k%2FDriveSync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheFlash2k%2FDriveSync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheFlash2k%2FDriveSync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheFlash2k%2FDriveSync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheFlash2k","download_url":"https://codeload.github.com/TheFlash2k/DriveSync/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246171922,"owners_count":20735092,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["google-drive","google-drive-api"],"created_at":"2025-03-29T10:29:25.104Z","updated_at":"2025-03-29T10:29:25.580Z","avatar_url":"https://github.com/TheFlash2k.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DriveSync - A much easier API to upload and create files/folders in Google Drive\r\n\r\nA simple Python3 based API which easy to use and user friendly function(s) to interact with the Google Drive API.\r\n\r\n# Usage:\r\nThere are two different classes that are usable.\r\n- ***Sync***\r\n- ***GD_API***\r\n\r\nNote: To know how to generate the json token, read [Google Drive API Token Generation](token_gen.md)\r\n\r\n## Sync:\r\nThe Sync class is built upon the GD_API class and all it simply does is upload files from a certain folder into another folder within the drive in an organized manner.\r\nThe Sync class will firstly create a parent folder from the argument `parent_folder_name`. Then, within that folder, different folders will be created such as, `Images, Audios, Videos, Documents` etc. The main reason behind creation of these folders is to keep everything organized during the syncing process. Everything is sync based on their mimetypes.\r\n\r\n### Example:\r\n```python\r\nfrom modules.sync import *\r\n \r\nsync = Sync (\r\n    folder_name=\"Folder\",            # This will be the name of the folder on the local drive that will be synced with the google drive.\r\n    parent_folder_name='DriveSync',  # The parent folder into which other folders will be created\r\n    post_folder_name='Uploaded',     # The name of the folder into which all the files be copied to onto the local drive once they're uploaded.\r\n    token_file='client_secret.json', # The `json` file that will be generated from developers.google.com\r\n    verbose=False\r\n)\r\n\r\nsync.init_sync() # This method will control everything, no need to configure anything else, just pass the valid arugments to the constructor and everything will work fine.\r\n```\r\n\r\n## GD_API:\r\nThis class simplifies everything from creation of the service to interact with the Google API and then invoking other methods and dealing with Mime-Types for each thing.\r\nI've managed to simplify each task so that it's as easy as invoking a method with correct arguments. These are a few important methods which are as easy to invoke as a `sum` function with 2 parameters (I'm bad at giving references ;-;). Following are the methods:\r\n```python\r\n# Details for each method is provided in the Examples section\r\nget_files_list()\r\nget_folder_id(folder_name)\r\nget_folder_name(folder_id)\r\ncheck_folder_exists(folder_name=None,folder_id=None)\r\ncreate_folder(folder_name,parent_folder_name=None,parent_folder_id=None)\r\nupload_file(file_name,parent_folder_name=None,parent_folder_id=None)\r\n```\r\n\r\n### Example:\r\n```python\r\nfrom modules.GD_API import GD_API\r\n\r\n# This constructor will only take the token file as an argument, and then will validate this token before returning a handle of the original google API.\r\napi = GD_API(\r\n    client_token_file='client_secret.json'\r\n)\r\n\r\n# Available methods:\r\n\r\n# This will return all the files in the drive of that particular user\r\nfile_list = api.get_files_list()\r\n\r\n# This will return the id of a folder name that is passed as its argument.\r\napi.get_folder_id(\r\n    folder_name='DriveSync'\r\n)\r\n\r\n# This will return the name of the folder who's id is passed as the argument.\r\napi.get_folder_name(\r\n    folder_id='1DqW-HBoC3W4BTcJUmHTEu871AplDwhTa'\r\n)\r\n\r\n# This method takes two values as its argument but only one can be set when called.\r\n# This method will look for the existence of a folder in the drive, the existence can be on the basis of the id or the name.\r\n## Examples:\r\napi.check_folder_exists(\r\n    folder_name=None,\r\n    folder_id=None\r\n)\r\n# For Name:\r\napi.check_folder_exists(\r\n    folder_name='DriveSync',\r\n    folder_id=None\r\n) # Here you can also just provide folder_name as folder_id is already default set to None\r\n# For ID:\r\napi.check_folder_exists(\r\n    folder_name=None,\r\n    folder_id='1DqW-HBoC3W4BTcJUmHTEu871AplDwhTa'\r\n) # Here you can also just provide folder_id as folder_name is already default set to None\r\n\r\n# This method will take as its argument at most 2 values, one will be the folder name and the other will be\r\n# either the parent folder name or its id. The parent folder means that you want to create the new folder inside an already existing folder that will be its parent.\r\n# You can call the function using the following conventions:\r\napi.create_folder('DriveSync') # This will create a folder named 'DriveSync' in the root of the Drive.\r\napi.create_folder(\r\n    folder_name='DriveSync',\r\n    parent_folder_name=None,\r\n    parent_folder_id=None\r\n) # This will be the same as the above calling.\r\n# Using name:\r\napi.create_folder('DriveSync', parent_folder_name='Parent') # This will create a folder named 'DriveSync' within another folder 'Parent'\r\napi.create_folder(\r\n    folder_name='DriveSync',\r\n    parent_folder_name='Parent',\r\n    parent_folder_id=None\r\n) # This will be the same as the above calling.\r\n# Using ID:\r\napi.create_folder('DriveSync', parent_folder_id='1DqW-HBoC3W4BTcJUmHTEu871AplDwhTa') # This will create a folder named 'DriveSync' within another folder who's id is : '1DqW-HBoC3W4BTcJUmHTEu871AplDwhTa'\r\napi.create_folder(\r\n    folder_name='DriveSync',\r\n    parent_folder_name=None,\r\n    parent_folder_id='1DqW-HBoC3W4BTcJUmHTEu871AplDwhTa'\r\n) # This will be the same as the above calling.\r\n\r\n# This method will be used to upload files to the drive. All the mime-types and everything has been taken care of behind the scenes and uploading is as easy as invoking this method.\r\napi.upload_file(\r\n    file_name='Test.txt',\r\n    parent_folder_name=None,\r\n    parent_folder_id=None\r\n) # This will upload the file 'Test.txt' to the root of the Drive.\r\n# Same as all the other methods, you can upload files within a certain directory and what not.\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheflash2k%2Fdrivesync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheflash2k%2Fdrivesync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheflash2k%2Fdrivesync/lists"}