feat: 初始化 iCloud 照片自动同步项目

This commit is contained in:
CHE LIANG ZHAO
2026-01-28 13:48:59 +08:00
commit 4c61fc6a3a
5 changed files with 177 additions and 0 deletions

6
.env.example Normal file
View File

@@ -0,0 +1,6 @@
# iCloud 同步配置示例
# 复制此文件为 .env 并修改配置
APPLE_ID=your@icloud.com
SYNC_INTERVAL=86400
PHOTOS_PATH=./photos

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# iCloud 同步忽略文件
config/
photos/
.env

52
docker-compose.yml Normal file
View File

@@ -0,0 +1,52 @@
services:
icloudpd:
image: boredazfcuk/icloudpd:latest
container_name: icloudpd
restart: unless-stopped
environment:
# ===== 基础配置 =====
TZ: Asia/Shanghai # 时区
apple_id: ${APPLE_ID:-your@icloud.com} # Apple ID
authentication_type: 2FA # 认证类型2FA 或 Web
icloud_china: "true" # 使用中国区 iCloud (icloud.com.cn)
auth_china: "true" # 使用中国区认证
# ===== 下载配置 =====
download_path: /data # 下载路径
folder_structure: "{:%Y/%m}" # 文件夹结构:按年/月分类
synchronisation_interval: ${SYNC_INTERVAL:-86400} # 同步间隔21600(6h)/43200(12h)/86400(24h)
download_delay: 0 # 首次下载延迟(分钟)
skip_check: "true" # 跳过新文件检查(大库必须开启)
download_threads: 10 # 下载线程数
# ===== 文件类型 =====
photo_size: original # 照片尺寸original/medium/thumb/adjusted/alternative
live_photo_size: original # 实况照片尺寸
# skip_videos: "true" # 跳过视频
# skip_live_photos: "true" # 跳过实况照片
# ===== 下载范围 =====
# recent_only: 100 # 只下载最近 N 张
# until_found: 50 # 找到 N 张已存在的停止(增量同步)
# photo_album: "相册名" # 只下载指定相册
# ===== 删除选项 =====
# auto_delete: "true" # 自动删除 iCloud 已删除的照片
# delete_after_download: "true" # 下载后从 iCloud 删除
# delete_accompanying: "true" # 删除 HEIC 时删除对应 JPG
# delete_empty_directories: "true" # 删除空目录
# ===== 格式转换 =====
# convert_heic_to_jpeg: "true" # HEIC 转 JPEG
# jpeg_quality: 90 # JPEG 质量 (0-100)
# jpeg_path: /data/jpeg # JPEG 保存路径
# ===== 通知配置 =====
notification_days: 7 # Cookie 过期提前通知天数
# notification_type: Telegram # 通知类型Telegram/Pushover/Discord/Webhook 等
# telegram_token: "your_bot_token" # Telegram Bot Token
# telegram_chat_id: "your_chat_id" # Telegram Chat ID
volumes:
- ${PHOTOS_PATH:-./photos}:/data # 照片保存目录
- ./config:/config # 配置和 cookie 目录

58
icloud.ps1 Normal file
View File

@@ -0,0 +1,58 @@
# iCloud 同步管理脚本
# 用法: .\icloud.ps1 <命令>
# 命令: auth, logs, status, restart, sync
param(
[Parameter(Position=0)]
[string]$Command
)
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $scriptDir
if (-not $Command) {
Write-Host "用法: .\icloud.ps1 <命令>" -ForegroundColor Cyan
Write-Host ""
Write-Host "命令:" -ForegroundColor Cyan
Write-Host " auth - 重新认证" -ForegroundColor White
Write-Host " logs - 查看实时日志" -ForegroundColor White
Write-Host " status - 查看容器状态" -ForegroundColor White
Write-Host " restart - 重启容器" -ForegroundColor White
Write-Host " sync - 立即触发同步" -ForegroundColor White
exit 0
}
switch ($Command) {
"auth" {
Write-Host "开始 iCloud 认证..." -ForegroundColor Green
Write-Host "请输入密码和验证码完成认证" -ForegroundColor Yellow
docker exec -it icloudpd sync-icloud.sh --Initialise
if ($LASTEXITCODE -eq 0) {
Write-Host "认证成功!" -ForegroundColor Green
} else {
Write-Host "认证失败,请重试" -ForegroundColor Red
}
}
"logs" {
Write-Host "查看实时日志 (Ctrl+C 退出)..." -ForegroundColor Cyan
docker logs -f icloudpd
}
"status" {
docker ps --filter "name=icloudpd" --format "table {{.Status}}\t{{.Ports}}"
docker logs --tail 10 icloudpd
}
"restart" {
Write-Host "重启容器..." -ForegroundColor Yellow
docker compose restart
Write-Host "完成!" -ForegroundColor Green
}
"sync" {
Write-Host "立即触发同步..." -ForegroundColor Yellow
docker exec icloudpd sync-icloud.sh --DownloadOnce
}
default {
Write-Host "未知命令: $Command" -ForegroundColor Red
Write-Host ""
Write-Host "可用命令: auth, logs, status, restart, sync" -ForegroundColor Cyan
}
}

57
icloud.sh Normal file
View File

@@ -0,0 +1,57 @@
#!/bin/bash
# iCloud 同步管理脚本
# 用法: ./icloud.sh <命令>
# 命令: auth, logs, status, restart, sync
cd "$(dirname "$0")"
show_help() {
echo -e "\033[36m用法: ./icloud.sh <命令>\033[0m"
echo ""
echo -e "\033[36m命令:\033[0m"
echo " auth - 重新认证"
echo " logs - 查看实时日志"
echo " status - 查看容器状态"
echo " restart - 重启容器"
echo " sync - 立即触发同步"
}
if [ -z "$1" ]; then
show_help
exit 0
fi
case $1 in
auth)
echo -e "\033[32m开始 iCloud 认证...\033[0m"
echo -e "\033[33m请输入密码和验证码完成认证\033[0m"
docker exec -it icloudpd sync-icloud.sh --Initialise
if [ $? -eq 0 ]; then
echo -e "\033[32m认证成功\033[0m"
else
echo -e "\033[31m认证失败请重试\033[0m"
fi
;;
logs)
echo -e "\033[36m查看实时日志 (Ctrl+C 退出)...\033[0m"
docker logs -f icloudpd
;;
status)
docker ps --filter "name=icloudpd" --format "table {{.Status}}\t{{.Ports}}"
docker logs --tail 10 icloudpd
;;
restart)
echo -e "\033[33m重启容器...\033[0m"
docker compose restart
echo -e "\033[32m完成\033[0m"
;;
sync)
echo -e "\033[33m立即触发同步...\033[0m"
docker exec icloudpd sync-icloud.sh --DownloadOnce
;;
*)
echo -e "\033[31m未知命令: $1\033[0m"
echo ""
show_help
;;
esac