Skip to content

Instantly share code, notes, and snippets.

@ei-grad
Created October 22, 2019 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ei-grad/88e4f7146b7935e638a1a47f370e85eb to your computer and use it in GitHub Desktop.
Save ei-grad/88e4f7146b7935e638a1a47f370e85eb to your computer and use it in GitHub Desktop.
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