diff options
Diffstat (limited to 'recover.sh')
-rwxr-xr-x | recover.sh | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/recover.sh b/recover.sh new file mode 100755 index 0000000..5c827aa --- /dev/null +++ b/recover.sh | |||
@@ -0,0 +1,49 @@ | |||
1 | LIMIT=5000 | ||
2 | read_dom () { | ||
3 | ORIGINAL_IFS=$IFS | ||
4 | IFS=\> | ||
5 | read -d \< ENTITY CONTENT | ||
6 | IFS=$ORIGINAL_IFS | ||
7 | } | ||
8 | |||
9 | repair_post_dates() { | ||
10 | local count=0 | ||
11 | local url=https://peppe.rs/posts/ | ||
12 | while read_dom; do | ||
13 | ((count++)) | ||
14 | if [ "$count" -ge "$LIMIT" ]; then | ||
15 | exit | ||
16 | fi | ||
17 | if [[ $ENTITY = "link" ]] ; then | ||
18 | local _f=${CONTENT##$url} | ||
19 | local f="posts/${_f%%/}.md" | ||
20 | elif [[ $ENTITY = "pubDate" ]] ; then | ||
21 | local d=$CONTENT | ||
22 | repair "$d" "$f" | ||
23 | fi | ||
24 | done | ||
25 | } | ||
26 | |||
27 | repair_art_dates() { | ||
28 | local f d | ||
29 | while mapfile -t -n 2 a && ((${#a[@]})); do | ||
30 | f=${a[0]} | ||
31 | d=${a[1]} | ||
32 | |||
33 | f=${f##src=\"/} | ||
34 | d=$(dateconv -i '%d/%m — %Y' "$d") | ||
35 | |||
36 | repair "$d" "$f" | ||
37 | done | ||
38 | } | ||
39 | |||
40 | repair() { | ||
41 | echo "[+] repairing $2" | ||
42 | touch -am -d "$1" "$2" | ||
43 | } | ||
44 | |||
45 | grep -B1 pubDate docs/index.xml | repair_post_dates | ||
46 | grep -Eo \ | ||
47 | -e 'src="/art/.*.png' \ | ||
48 | -e '[0-9]{2}/[0-9]{2}...[0-9]{4}' \ | ||
49 | docs/art/index.html | repair_art_dates | ||