-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
120 lines (91 loc) · 3.28 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Google Drive Fetch
Automatically fetches text documents (Google Docs and .md) from Google Drive folders and saves them as markdown files in specified local directories. Built primarily for syncing meeting transcripts to Obsidian vaults.
This project was created by Matt O'Brien ([@mgmobrien](https://github.com/mgmobrien/)) with Claude 3.5 Sonnet in Zed and Obsidian. Claude wrote the code and documentation with Matt's supervision and editing.
## Features
- One-way sync from Google Drive to local directories
- Supports both Google Docs and markdown files
- Handles multiple folder mappings
- Adds configurable front matter/headers to files
- Maintains sync state to avoid duplicates
- Date parsing from various filename formats
## Installation
1. Clone the repository:
```bash
git clone https://github.com/mgmobrien/google-drive-fetch.git
cd google-drive-fetch
```
2. Install dependencies:
```bash
pip install google-auth google-auth-oauthlib google-auth-httplib2 google-api-python-client pyyaml
```
## Google Cloud Setup
1. Create a new project in Google Cloud Console:
- Go to [Google Cloud Console](https://console.cloud.google.com)
- Create a new project or select an existing one
- Enable the Google Drive API for your project
2. Create a service account:
- Go to IAM & Admin > Service Accounts
- Click "Create Service Account"
- Name it (e.g., "drive-fetch")
- No need to grant project roles
- Click "Create and Continue"
3. Create and download credentials:
- Select your new service account
- Go to "Keys" tab
- Add new key > Create new key > JSON
- Save the downloaded file as `credentials/service-account.json`
4. Share folders:
- In Google Drive, share each folder you want to fetch from
- Share with the service account email (found in credentials file)
- Only needs "Viewer" access
## Configuration
1. Copy the example config file:
```bash
cp config.example.yaml config.yaml
```
2. Update `config.yaml` with your folder mappings:
```yaml
credentials:
service_account_path: "credentials/service-account.json"
folders:
transcripts: # This name is just for you
google_drive_id: "1xxx..." # Folder ID from Google Drive URL
local_path: "/path/to/local/folder"
meeting_notes:
google_drive_id: "1yyy..."
local_path: "/different/local/path"
```
To get a folder's ID:
1. Open the folder in Google Drive
2. The ID is in the URL: `https://drive.google.com/drive/folders/THIS_IS_THE_ID`
## Usage
Run the script:
```bash
python src/main.py
```
For automated running:
### macOS (launchd)
```bash
# Copy the plist file
cp launchd/com.mattobrien.transcriptsyncer.plist ~/Library/LaunchAgents/
# Edit paths in the plist file to match your setup
# Load the service
launchctl load ~/Library/LaunchAgents/com.mattobrien.transcriptsyncer.plist
```
### Linux (cron)
```bash
# Add to crontab (runs every 5 minutes)
*/5 * * * * cd /path/to/google-drive-fetch && ./venv/bin/python src/main.py
```
## Logs
Logs are written to:
- `logs/transcript_syncer.log` - All activity
- `logs/launchd_err.log` - Errors only
## License
All code was written by Claude 3.5 Sonnet with
MIT
## Contributing
Pull requests welcome! Some areas that could use improvement:
- Support for other document sources (Zoom, Otter, etc.)
- More flexible date parsing
- Additional front matter templates