blob: 9b3749d94e0e4a01470e02facef60fc32db4a78c (
plain)
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
|
import os
from os import walk
import os.path
def convert_links_to_gemini(domain):
for file in os.listdir("output/gemini"):
processed = ""
f = open("output/gemini/" + file, "r")
for line in f.readlines():
if ".html" in line and "http" not in line or domain in line:
line = line.replace("html", "gmi")
url = line.split(" ")[1]
link = url.split("/")[-1]
line = line.replace(str(url), str(link))
processed += line
else:
processed += line
f.close()
f = open("output/gemini/" + file, "w")
f.write(processed)
f.close()
return("links are converted to gemini (3/3)")
|