z230 - Joplin mirror skripty, store_cda_batch v1.2, vyrazeni Evernote exportu a en_backup.db z gitu
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#!/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", [])))
|
||||
Reference in New Issue
Block a user