Go to file
Tiger Ren 32b24c3a11 Add documentation for `get_onedrive_token.py` script in README files and update `run_ps_download.py` to include access token handling. 2025-05-09 01:16:50 +08:00
Download-ODLivePhotos.ps1 Add scripts for downloading Live Photos from OneDrive and syncing files 2025-04-04 01:02:54 +08:00
Download-ODLivePhotosV2.ps1 Add scripts for downloading Live Photos from OneDrive and syncing files 2025-04-04 01:02:54 +08:00
Download.ps1 Add scripts for downloading Live Photos from OneDrive and syncing files 2025-04-04 01:02:54 +08:00
README.md Add documentation for `get_onedrive_token.py` script in README files and update `run_ps_download.py` to include access token handling. 2025-05-09 01:16:50 +08:00
README_CN.md Add documentation for `get_onedrive_token.py` script in README files and update `run_ps_download.py` to include access token handling. 2025-05-09 01:16:50 +08:00
get_onedrive_token.py Add documentation for `get_onedrive_token.py` script in README files and update `run_ps_download.py` to include access token handling. 2025-05-09 01:16:50 +08:00
requirements.txt Add documentation for `get_onedrive_token.py` script in README files and update `run_ps_download.py` to include access token handling. 2025-05-09 01:16:50 +08:00
run_ps_download.py Add documentation for `get_onedrive_token.py` script in README files and update `run_ps_download.py` to include access token handling. 2025-05-09 01:16:50 +08:00
scan_lib.py Add scripts for downloading Live Photos from OneDrive and syncing files 2025-04-04 01:02:54 +08:00
scan_lib.sh Add scripts for downloading Live Photos from OneDrive and syncing files 2025-04-04 01:02:54 +08:00
sync.py Add documentation for `get_onedrive_token.py` script in README files and update `run_ps_download.py` to include access token handling. 2025-05-09 01:16:50 +08:00
sync_task.py Add scripts for downloading Live Photos from OneDrive and syncing files 2025-04-04 01:02:54 +08:00

README.md

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:

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:

# 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:

# 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:

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:

.\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