Compare commits
3 commits
0ecac665de
...
7e33b51819
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e33b51819 | ||
|
|
9690bfa3b1 | ||
|
|
ba418101a9 |
1 changed files with 2 additions and 15 deletions
17
publish.py
17
publish.py
|
|
@ -14,7 +14,7 @@ htmltemplate = """<!DOCTYPE html>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||||
<title>{title}</title>
|
<title>{title}</title>
|
||||||
<style>
|
<style>
|
||||||
html {{ margin: 20px; }}
|
html {{ margin: 20px; font-size: large; }}
|
||||||
body {{ margin: auto; max-width: 800px; text-align: justify; }}
|
body {{ margin: auto; max-width: 800px; text-align: justify; }}
|
||||||
audio {{ height: 14px}}
|
audio {{ height: 14px}}
|
||||||
img {{ width: 100% }}
|
img {{ width: 100% }}
|
||||||
|
|
@ -44,6 +44,7 @@ with open(settingsfile, "r", encoding="utf-8") as file:
|
||||||
htmlhome = "<h1>{}</h1><p>{}</p>".format(index['title'], index['description'])
|
htmlhome = "<h1>{}</h1><p>{}</p>".format(index['title'], index['description'])
|
||||||
gmihome = "# {}\n{}".format(index['title'], index['description'])
|
gmihome = "# {}\n{}".format(index['title'], index['description'])
|
||||||
|
|
||||||
|
shutil.rmtree('out')
|
||||||
os.makedirs("out/html", exist_ok=True)
|
os.makedirs("out/html", exist_ok=True)
|
||||||
os.makedirs("out/gmi", exist_ok=True)
|
os.makedirs("out/gmi", exist_ok=True)
|
||||||
|
|
||||||
|
|
@ -95,20 +96,6 @@ for folderinfo in index['folders']:
|
||||||
htmlhome += "<li><a href=\"{}\">{}</a> [<a href=\"{}\">epub</a>]</li>".format(outfilename.replace('.md', '.html'),filetitle,outfilename.replace('.md', '.epub'))
|
htmlhome += "<li><a href=\"{}\">{}</a> [<a href=\"{}\">epub</a>]</li>".format(outfilename.replace('.md', '.html'),filetitle,outfilename.replace('.md', '.epub'))
|
||||||
gmihome += "\n=> {} {}".format(outfilename.replace('.md', '.gmi').replace(' ', '%20'), filetitle)
|
gmihome += "\n=> {} {}".format(outfilename.replace('.md', '.gmi').replace(' ', '%20'), filetitle)
|
||||||
|
|
||||||
elif fileextension == ".wav" or fileextension == ".3gp":
|
|
||||||
|
|
||||||
# todo use builtin python library
|
|
||||||
outfilename = unidecode.unidecode(fileroot) + ".mp3"
|
|
||||||
subprocess.run(["ffmpeg",
|
|
||||||
"-i",
|
|
||||||
os.path.join(folderinfo['folder'], filename),
|
|
||||||
os.path.join('out/html', outfilename)])
|
|
||||||
htmlhome += "<li>{}</li><audio controls><source src=\"{}\"></audio>".format(filetitle, outfilename)
|
|
||||||
|
|
||||||
elif fileextension == ".mp3":
|
|
||||||
shutil.copy(os.path.join(folderinfo['folder'], filename), os.path.join('out/html', outfilename))
|
|
||||||
htmlhome += "<li>{}</li><audio controls><source src=\"{}\"></audio>".format(filetitle, outfilename)
|
|
||||||
|
|
||||||
htmlhome += "\n</ul>"
|
htmlhome += "\n</ul>"
|
||||||
|
|
||||||
with open("out/html/index.html", "w", encoding="utf-8") as htmlindex:
|
with open("out/html/index.html", "w", encoding="utf-8") as htmlindex:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue