{"id":22432706,"url":"https://github.com/1999azzar/python-google-drive-sync-script","last_synced_at":"2025-03-27T07:42:52.140Z","repository":{"id":217254875,"uuid":"743391073","full_name":"1999AZZAR/Python-Google-Drive-Sync-Script","owner":"1999AZZAR","description":null,"archived":false,"fork":false,"pushed_at":"2024-01-15T06:33:58.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T12:45:50.673Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/1999AZZAR.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":"2024-01-15T06:09:41.000Z","updated_at":"2024-01-15T06:34:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"97a2e45b-c8a8-45c5-a4c0-b590d9f39190","html_url":"https://github.com/1999AZZAR/Python-Google-Drive-Sync-Script","commit_stats":null,"previous_names":["1999azzar/python-google-drive-sync-script"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1999AZZAR%2FPython-Google-Drive-Sync-Script","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1999AZZAR%2FPython-Google-Drive-Sync-Script/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1999AZZAR%2FPython-Google-Drive-Sync-Script/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1999AZZAR%2FPython-Google-Drive-Sync-Script/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/1999AZZAR","download_url":"https://codeload.github.com/1999AZZAR/Python-Google-Drive-Sync-Script/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245806048,"owners_count":20675292,"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":[],"created_at":"2024-12-05T22:12:37.121Z","updated_at":"2025-03-27T07:42:52.121Z","avatar_url":"https://github.com/1999AZZAR.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google Drive Sync (GDS) Script README\n\n## Table of Contents\n\n1. [Introduction](#1-introduction)\n2. [Setup](#2-setup)\n   - [Prerequisites](#prerequisites)\n   - [Configuration](#configuration)\n3. [Script Overview](#3-script-overview)\n   - [Dependencies](#dependencies)\n   - [Database Setup](#database-setup)\n   - [Google Drive API](#google-drive-api)\n   - [Functions](#functions)\n   - [Main Loop](#main-loop)\n4. [Usage](#4-usage)\n5. [Monitoring and Automation](#5-monitoring-and-automation)\n6. [File Log Database](#6-file-log-database)\n7. [Error Handling](#7-error-handling)\n\n## 1. Introduction\n\nThe Google Drive Sync (GDS) script facilitates seamless synchronization between a designated Google Drive folder and a local directory. It harnesses the power of the Google Drive API to detect changes in the Drive, automatically fetching new files, and efficiently managing local deletions.\n\n## 2. Setup\n\n### Prerequisites\n\n- **Python**: Ensure Python is installed on your machine.\n- **Google API Credentials**: Obtain API credentials and an API key.\n- **SQLite Database**: Set up an SQLite database for tracking file information.\n\n### Configuration\n\nEdit the `.secret` file to provide the API key, credentials path, folder ID, and download path.\n\n## 3. Script Overview\n\n### Dependencies\n\n- `os`: Operating system interactions.\n- `googleapiclient`: Google API client library.\n- `time`: Time-related functions.\n- `io`: File stream operations.\n- `sqlite3`: SQLite database connectivity.\n- `datetime`: Timestamp generation.\n\n### Database Setup\n\nThe script establishes a connection to an SQLite database (`file_log.db`) to log detailed information about downloaded files. It creates a `file_log` table if it doesn't exist, containing columns for file ID, name, download timestamp, and size.\n\n### Google Drive API\n\nGDS leverages the Google Drive API to interact seamlessly with the specified Drive folder. It performs operations such as listing files, downloading files, and retrieving file information.\n\n### Functions\n\n- `list_files(service, folder_id)`: Lists files in the specified Google Drive folder.\n- `download_file(service, file_id, file_name, download_path)`: Downloads a file from Google Drive and logs detailed information in the database.\n- `remove_file(file_name, download_path)`: Removes a file from the local directory and the database.\n\n### Main Loop\n\nThe script operates within an infinite loop, checking for changes in the Google Drive folder at 15-second intervals. It efficiently downloads new files, removes deleted files, and dynamically updates the file list.\n\n## 4. Usage\n\n- Execute the script to commence the synchronization process.\n- Monitor the console for real-time download and deletion notifications.\n\n## 5. Monitoring and Automation\n\nGDS seamlessly integrates into background processes, making it ideal for automated execution. Consider configuring system tools (e.g., cron jobs on Unix-based systems) for scheduled runs.\n\n## 6. File Log Database\n\nThe `file_log.db` database maintains an exhaustive record of downloaded files, encompassing their names, download timestamps, and sizes.\n\n## 7. Error Handling\n\nWhile the script lacks explicit error-handling mechanisms, users are encouraged to enhance this aspect based on their specific use cases and potential issues.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1999azzar%2Fpython-google-drive-sync-script","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F1999azzar%2Fpython-google-drive-sync-script","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1999azzar%2Fpython-google-drive-sync-script/lists"}