d2e8a70bfe
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
# Smaze VSECHNY polozky z Joplin Serveru (pro cisty full-sync). Jednorazova pomucka.
|
|
import json, urllib.request
|
|
|
|
BASE = "https://joplin.buzalka.cz"
|
|
EMAIL = "vladimir.buzalka@buzalka.cz"
|
|
PASSWORD = "Vlado7309208104++"
|
|
|
|
tok = json.loads(urllib.request.urlopen(urllib.request.Request(
|
|
BASE + "/api/sessions",
|
|
data=json.dumps({"email": EMAIL, "password": PASSWORD}).encode(),
|
|
headers={"Content-Type": "application/json"})).read())["id"]
|
|
|
|
|
|
def req(method, path, data=None):
|
|
r = urllib.request.Request(BASE + path, data=data, method=method,
|
|
headers={"X-API-AUTH": tok})
|
|
return urllib.request.urlopen(r, timeout=60).read().decode()
|
|
|
|
|
|
deleted = 0
|
|
while True:
|
|
page = json.loads(req("GET", "/api/items/root/children"))
|
|
items = page.get("items", [])
|
|
if not items:
|
|
break
|
|
for it in items:
|
|
req("DELETE", "/api/items/root:/{}:".format(it["name"]))
|
|
deleted += 1
|
|
print(" smazano {} (has_more={})".format(deleted, page.get("has_more")))
|
|
|
|
print("CELKEM smazano polozek:", deleted)
|
|
chk = json.loads(req("GET", "/api/items/root/children"))
|
|
print("zbyva polozek na serveru:", len(chk.get("items", [])))
|