34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
import subprocess, json
|
|
from urllib.request import Request, urlopen
|
|
|
|
API_KEY = "GsWQUTR6EXlkKp1M82jDJ3KmzhM0fMAbbIbfHDyI"
|
|
API_URL = "http://localhost:2283/api"
|
|
|
|
# Correct date: Aug 24, 2012
|
|
correct_date = "2012-08-24T12:00:00.000Z"
|
|
|
|
files = [
|
|
"MVI_0440.jpg", "MVI_0444.jpg", "MVI_0446.jpg", "MVI_0448.jpg",
|
|
"MVI_0454.jpg", "MVI_0462.jpg", "MVI_0463.jpg", "MVI_0465.jpg",
|
|
"MVI_0466.jpg", "MVI_0467.jpg", "MVI_0468.jpg", "MVI_0469.jpg",
|
|
"MVI_0470.jpg", "MVI_0495.jpg",
|
|
]
|
|
|
|
for fname in files:
|
|
# Find in 2015/02 where they were moved
|
|
result = subprocess.run([
|
|
"docker", "exec", "immich_postgres", "psql", "-U", "postgres", "-d", "immich", "-t", "-c",
|
|
f"SELECT id FROM asset WHERE \"originalFileName\" = '{fname}' AND \"deletedAt\" IS NULL;"
|
|
], capture_output=True, text=True)
|
|
asset_id = result.stdout.strip()
|
|
|
|
if asset_id:
|
|
data = json.dumps({"dateTimeOriginal": correct_date}).encode()
|
|
req = Request(f"{API_URL}/assets/{asset_id}", data=data, method="PUT",
|
|
headers={"x-api-key": API_KEY, "Content-Type": "application/json"})
|
|
urlopen(req)
|
|
print(f"Fixed {fname} -> 2012-08-24")
|
|
else:
|
|
print(f"NOT FOUND: {fname}")
|