97 lines
3.2 KiB
Markdown
97 lines
3.2 KiB
Markdown
# HEIC Sync
|
|
|
|
A collection of scripts for managing and syncing photos from OneDrive, with special support for Live Photos.
|
|
|
|
## Overview
|
|
|
|
This repository contains a set of Python and PowerShell scripts that help with:
|
|
1. Downloading Live Photos from OneDrive
|
|
2. Syncing photos between different locations
|
|
3. Scanning photo libraries
|
|
4. Managing photo backups
|
|
|
|
## Scripts
|
|
|
|
### Python Scripts
|
|
|
|
#### `get_onedrive_token.py`
|
|
A Python script to obtain an OAuth2 access token for OneDrive using the official OneDrive client ID. This is required for accessing OneDrive's API.
|
|
|
|
Usage:
|
|
```bash
|
|
python get_onedrive_token.py
|
|
```
|
|
|
|
The script will:
|
|
1. Open your browser for authentication
|
|
2. Handle the OAuth2 flow
|
|
3. Save the token data (including refresh token) to `onedrive_token.json`
|
|
|
|
Note: The script uses the official OneDrive client ID and doesn't require any additional setup.
|
|
|
|
#### `run_ps_download.py`
|
|
A Python wrapper for the PowerShell Live Photo downloader. It handles the execution of the PowerShell script with proper year/month path organization.
|
|
|
|
Usage:
|
|
```bash
|
|
# Process current month (and last month if today is the 1st)
|
|
python run_ps_download.py --base-save-to "D:\Photos\OneDrive-Photo" --base-path-to-scan "\Photos\Auto-saved"
|
|
|
|
# Process specific month (2 for last month, 3 for month before last, etc.)
|
|
python run_ps_download.py --base-save-to "D:\Photos\OneDrive-Photo" --base-path-to-scan "\Photos\Auto-saved" --months 2
|
|
```
|
|
|
|
#### `sync_task.py`
|
|
Handles syncing of photos between different locations, organizing them by year/month.
|
|
|
|
Usage:
|
|
```bash
|
|
# Sync OneDrive to Local(Backup)
|
|
python sync_task.py d:\OneDrive\Photos\Auto-saved\ D:\Photos\Auto-saved --months 1
|
|
|
|
# Sync Photo to NAS
|
|
python sync_task.py d:\OneDrive\Photos\Auto-saved\ \\tiger-nas\Multimedia\Photos\ --months 1
|
|
|
|
# Sync Local Motion to NAS
|
|
python sync_task.py D:\Photos\OneDrive-Photo\ \\tiger-nas\Multimedia\Photos\ --months 1
|
|
```
|
|
|
|
#### `scan_lib.py`
|
|
Scans a Immich library using its API. This is useful for updating your media server's photo library.
|
|
|
|
Usage:
|
|
```bash
|
|
python scan_lib.py
|
|
```
|
|
|
|
### PowerShell Scripts
|
|
|
|
#### `Download-ODLivePhotosV2.ps1`
|
|
The main script for downloading Live Photos from OneDrive. It handles authentication and downloading of both the image and video components of Live Photos.
|
|
|
|
Usage:
|
|
```powershell
|
|
.\Download-ODLivePhotosV2.ps1 -SaveTo "C:\Live Photos" -PathToScan "\Pictures\Camera Roll"
|
|
```
|
|
|
|
## Requirements
|
|
|
|
- Python 3.x
|
|
- PowerShell 5.1 or later
|
|
- Microsoft Edge WebView2 Runtime (for Live Photo downloads)
|
|
- OneDrive account with Live Photos
|
|
- Immich photo server (for library scanning)
|
|
|
|
## Notes
|
|
|
|
- The scripts are designed to work with a year/month folder structure
|
|
- Live Photo downloads require authentication through OneDrive
|
|
- Some scripts may need to be run multiple times for large libraries due to potential OneDrive API limitations
|
|
- Make sure to have sufficient storage space when downloading Live Photos, as they consist of both image and video files
|
|
|
|
## Error Handling
|
|
|
|
- The scripts include basic error handling and will skip already downloaded files
|
|
- If OneDrive services are temporarily unavailable, you can safely rerun the scripts later
|
|
- The scripts maintain the original folder structure from OneDrive
|