Fix GoPro delete API: remove erroneous DCIM/ prefix from delete path, use correct bulk endpoint
This commit is contained in:
13
app.py
13
app.py
@@ -1928,19 +1928,19 @@ def clear_all():
|
||||
gopro_deleted = 0
|
||||
|
||||
def _delete_file(folder: str, filename: str) -> bool:
|
||||
raw_path = f"DCIM/{folder}/{filename}"
|
||||
encoded = quote(raw_path, safe="")
|
||||
# GoPros vary in whether they accept the path encoded or literal.
|
||||
# The Open GoPro API expects path={folder}/{filename} WITHOUT a DCIM/ prefix.
|
||||
raw_path = f"{folder}/{filename}"
|
||||
encoded_path = quote(raw_path, safe="")
|
||||
endpoints = [
|
||||
f"/gopro/media/delete/file?path={encoded_path}",
|
||||
f"/gopro/media/delete/file?path={raw_path}",
|
||||
f"/gopro/media/delete/file?path={encoded}",
|
||||
]
|
||||
for ep in endpoints:
|
||||
try:
|
||||
r = gopro_get(ep)
|
||||
if r.status_code in (200, 204):
|
||||
return True
|
||||
# Some firmwares expect POST
|
||||
# Some firmware variants expect POST
|
||||
r = gopro_post(ep)
|
||||
if r.status_code in (200, 204):
|
||||
return True
|
||||
@@ -1961,9 +1961,8 @@ def clear_all():
|
||||
remaining = _list_all_media()
|
||||
if remaining:
|
||||
for fallback in (
|
||||
"/gp/gpControl/command/storage/delete/all",
|
||||
"/gopro/camera/storage/delete/all",
|
||||
"/gopro/media/delete/all?file_system=SD",
|
||||
"/gopro/camera/storage/delete/all?file_system=SD",
|
||||
):
|
||||
try:
|
||||
r = gopro_get(fallback)
|
||||
|
||||
Reference in New Issue
Block a user