Add script that checks if pad is already moved
This commit is contained in:
parent
dea3fa9fe6
commit
6f7c991948
2 changed files with 29 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,7 +2,9 @@
|
|||
__pycache__
|
||||
venv/
|
||||
images/
|
||||
pads/
|
||||
pads.json
|
||||
new_pads.json
|
||||
# ---> Node
|
||||
# Logs
|
||||
logs
|
||||
|
|
27
hedgedoc-is-moved.py
Normal file
27
hedgedoc-is-moved.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
import requests
|
||||
import json
|
||||
import os
|
||||
|
||||
from os.path import exists
|
||||
|
||||
pads_json = []
|
||||
new_json= []
|
||||
|
||||
if exists("pads.json"):
|
||||
with open("pads.json", "r") as f:
|
||||
old_file = json.load(f)
|
||||
|
||||
pads_json.extend(old_file)
|
||||
|
||||
for pad in pads_json:
|
||||
print("Downloading: " + pad['oldUrl'] + "/download")
|
||||
r = requests.head(pad['oldUrl'] + "/download")
|
||||
if int(r.headers['content-length']) > 150:
|
||||
new_json.append(pad)
|
||||
|
||||
|
||||
with open("new_pads.json", "w") as f:
|
||||
f.write(json.dumps(new_json))
|
||||
|
||||
else:
|
||||
print("Give me pads.json")
|
Loading…
Add table
Reference in a new issue