This commit is contained in:
parent
9784a9ccba
commit
000fdcb06c
1 changed files with 5 additions and 4 deletions
|
@ -40,7 +40,8 @@ with open("index.gmi", "w", encoding="utf-8") as f:
|
||||||
for x in myresult:
|
for x in myresult:
|
||||||
path = path_regex.findall(x[0])[0]
|
path = path_regex.findall(x[0])[0]
|
||||||
path_with_dashes = path.replace("/","-")
|
path_with_dashes = path.replace("/","-")
|
||||||
filename = quote(quote(filename_regex.findall(x[0])[0]))
|
title = filename_regex.findall(x[0])[0]
|
||||||
|
filename = re.sub(r'\W+','', title)
|
||||||
|
|
||||||
with open("index.gmi", "a", encoding="utf-8") as f:
|
with open("index.gmi", "a", encoding="utf-8") as f:
|
||||||
f.write(f'=> {path}/{filename}.gmi {path_with_dashes} - {x[1]}\n')
|
f.write(f'=> {path}/{filename}.gmi {path_with_dashes} - {x[1]}\n')
|
||||||
|
@ -51,9 +52,9 @@ for x in myresult:
|
||||||
except OSError:
|
except OSError:
|
||||||
print (f"Creation of the directory {path} failed")
|
print (f"Creation of the directory {path} failed")
|
||||||
|
|
||||||
if not os.path.isfile(f'{path}/"{filename}".gmi'):
|
if not os.path.isfile(f'{path}/{filename}.gmi'):
|
||||||
print(f"creating {path}/\"{filename}\".gmi")
|
print(f"creating {path}/{filename}.gmi")
|
||||||
with open(f'{path}/"{filename}".gmi', "w", encoding="utf-8") as f:
|
with open(f'{path}/{filename}.gmi', "w", encoding="utf-8") as f:
|
||||||
f.write(f"# {x[1]}\n\n")
|
f.write(f"# {x[1]}\n\n")
|
||||||
f.write(f"Publié le {path}\n\n")
|
f.write(f"Publié le {path}\n\n")
|
||||||
f.write(html2markdown.convert(x[2]))
|
f.write(html2markdown.convert(x[2]))
|
||||||
|
|
Loading…
Reference in a new issue