72 lines
2.5 KiB
Python
72 lines
2.5 KiB
Python
import urllib.request
|
|
import json
|
|
import ssl
|
|
|
|
TOKEN = "BYnPaAb6kZN7r3dz0F1rrLS1ksXwl5zoGPD4L2aS22HAosABsIMOMHqnxfO5neh0AKioVO"
|
|
BASE_URL = "https://api.osf.io/v2"
|
|
|
|
# IDs of the Intellecton Hypothesis, Fieldprint Framework, and the Public Declaration
|
|
SPARED_NODES = ["7s3ta", "q23zs", "f53q2"]
|
|
|
|
ctx = ssl.create_default_context()
|
|
ctx.check_hostname = False
|
|
ctx.verify_mode = ssl.CERT_NONE
|
|
|
|
def main():
|
|
req = urllib.request.Request(f"{BASE_URL}/users/me/nodes/", headers={"Authorization": f"Bearer {TOKEN}"})
|
|
try:
|
|
with urllib.request.urlopen(req, context=ctx) as response:
|
|
data = json.loads(response.read().decode())
|
|
nodes = data.get("data", [])
|
|
except Exception as e:
|
|
print(f"Failed to fetch nodes: {e}")
|
|
return
|
|
|
|
for n in nodes:
|
|
nid = n.get("id")
|
|
attr = n.get("attributes", {})
|
|
title = attr.get("title", "")
|
|
description = attr.get("description", "") or ""
|
|
|
|
if nid in SPARED_NODES:
|
|
print(f"Skipping core node: {title} ({nid})")
|
|
continue
|
|
|
|
if title.startswith("[ARCHIVAL RECORD]"):
|
|
print(f"Already archived: {title} ({nid})")
|
|
continue
|
|
|
|
new_title = f"[ARCHIVAL RECORD] {title}"
|
|
disclaimer = "Historical Archive: This node contains early philosophical and theoretical explorations. For the rigorous mathematical formalization of this framework, please refer to the canonical publication: The Theory of Recursive Coherence.\n\n"
|
|
|
|
# Don't duplicate the disclaimer if it's already there (though title check handles most cases)
|
|
if disclaimer in description:
|
|
new_desc = description
|
|
else:
|
|
new_desc = disclaimer + description
|
|
|
|
payload = {
|
|
"data": {
|
|
"type": "nodes",
|
|
"id": nid,
|
|
"attributes": {
|
|
"title": new_title,
|
|
"description": new_desc
|
|
}
|
|
}
|
|
}
|
|
|
|
patch_req = urllib.request.Request(f"{BASE_URL}/nodes/{nid}/", data=json.dumps(payload).encode('utf-8'), headers={
|
|
"Authorization": f"Bearer {TOKEN}",
|
|
"Content-Type": "application/json"
|
|
}, method="PATCH")
|
|
|
|
try:
|
|
with urllib.request.urlopen(patch_req, context=ctx) as patch_resp:
|
|
print(f"Successfully archived: {nid} -> {new_title}")
|
|
except Exception as e:
|
|
print(f"Failed to archive {nid}: {e}")
|
|
|
|
if __name__ == '__main__':
|
|
main()
|