Created
October 22, 2019 06:53
-
-
Save ei-grad/88e4f7146b7935e638a1a47f370e85eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
from urllib.parse import quote | |
index = [] | |
for i in sorted(Path('.').iterdir()): | |
index.append(i) | |
with open('index.html', 'w') as f: | |
f.write('<html><body><center>') | |
for n, i in enumerate(index): | |
with (i.parent / (i.stem + '.html')).open('w') as f2: | |
f2.write(( | |
'<html><body>' | |
'<h1>{name}</h1>' | |
'<div><video width="720" height="400" autoplay controls>' | |
'<source src="{link}">' | |
'</video></div>' | |
).format( | |
name=i.stem, | |
link=quote(i.name), | |
)) | |
if n < len(index) - 1: | |
f2.write('<a href="{next_html}"><div>Next: {next_name}<div></a>'.format( | |
next_name=index[n+1].stem, | |
next_html=quote(index[n+1].stem + '.html'), | |
)) | |
f.write('<h3><a href="%s">%s</a></h3>' % ( | |
quote(i.stem + '.html'), i.stem)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment