-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharchiwizuj-pady.py
42 lines (39 loc) · 1.27 KB
/
archiwizuj-pady.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
import subprocess
import datetime
import re
nowe_spotkania = ""
with open("Spotkania.md") as f:
for line in f:
if line.startswith("[") and "pad.hs-ldz.pl" in line:
data = line.split("[")[1].split("]")[0]
orig_url = line.split("(")[1].split(")")[0]
url = orig_url.split("?")[0].strip("#")
print(data, url, repr(line))
fname = "Spotkania::" + data.replace(" ", "-")
with open(fname + ".md", "w") as f:
s = subprocess.check_output(
["curl", "-s", url + "/download"], encoding="utf-8"
)
f.write(
s
+ "\n***\nPrzemigrowano z pada "
+ url
+ ". Znajdziesz tam historię edycji sprzed migracji.\n***"
)
opis = re.split(".* [-–] (.*)$", line)[1]
line = (
"[["
+ data
+ "|"
+ fname
+ "]] <sup>("
+ "[pad]("
+ url
+ "))</sup> - "
+ opis
+ "\n"
)
nowe_spotkania += line
with open("Spotkania.md", "w") as f:
f.write(nowe_spotkania)