From 8027fce02e06fdfdc43d40fdec77a3bc4c56ac82 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 10 Jan 2023 23:05:36 +0100 Subject: [PATCH 01/10] encode --- encode.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 encode.py diff --git a/encode.py b/encode.py new file mode 100755 index 0000000..81585ca --- /dev/null +++ b/encode.py @@ -0,0 +1,48 @@ +#! /usr/bin/env python3 + +import os +import subprocess + + +def encode(input_file, output_file): + output_directory = os.path.dirname(output_file) + os.makedirs(output_directory, exist_ok=True) + if not os.path.exists(output_file): + subprocess.call([ + 'ffmpeg', + '-i', input_file, + '-codec:a', 'libopus', + '-codec:v', 'libx264', + '-preset', 'veryslow', + '-qp', '23', + '-movflags', '+faststart', + '-pix_fmt', 'yuv420p', + output_file + ]) + + +def main(): + file = os.path.realpath(__file__) + root = os.path.dirname(file) + raw_root = os.path.join(root, 'raw') + web_root = os.path.join(root, 'web') + print(f'← {raw_root}') + print(f'→ {web_root}') + tasks = [] + for directory, directories, files in os.walk(raw_root): + for file in files: + relative_directory = os.path.relpath(directory, raw_root) + name, ext = os.path.splitext(file) + relative_name = os.path.join(relative_directory, name) + tasks.append((relative_name, ext)) + for relative_name, ext in sorted(tasks): + raw_file = os.path.join(raw_root, f'{relative_name}{ext}') + web_file = os.path.join(web_root, f'{relative_name}.mp4') + print() + print(f'← {raw_file}') + print(f'→ {web_file}') + encode(raw_file, web_file) + + +if __name__ == '__main__': + main() From 89e92e116047ba9b05df588342c3c2eb017551c6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 10 Jan 2023 23:05:56 +0100 Subject: [PATCH 02/10] css --- index.css | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 index.css diff --git a/index.css b/index.css new file mode 100644 index 0000000..e69de29 From 9cf9eb8e7e977ccd583cab0f12a798bb360b32e7 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 10 Jan 2023 23:06:09 +0100 Subject: [PATCH 03/10] build/nav --- build.py | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100755 build.py diff --git a/build.py b/build.py new file mode 100755 index 0000000..f7a0e3f --- /dev/null +++ b/build.py @@ -0,0 +1,106 @@ +#! /usr/bin/env python3 + +import os +import subprocess + +SECTIONS = { + 'drift': 'Drift', + 'fs': 'FreeStyle', + 'k': 'K projects', + 'lol': 'LOL', + 'pf': 'Press Forward', + 'ta': 'Time Attack', + 'trial': 'Trial', +} + + +def card(name, web, raw): + return f'''\ +
+ +
+{name} +
+''' + + +def a(href, text, active=False): + html = ['{text}') + return str().join(html) + + +def nav(sections, active): + html = ['') + return str().join(html) + + +def body(sections): + html = [] + for section in sections.values(): + html.append(f'
') + html.append(section['content']) + html.append('
') + return str().join(html) + + +def html(body): + return f'''\ + + + + + +TrackMania vidz + + + + + +{body} + + + +''' + + +def main(): + file = os.path.realpath(__file__) + root = os.path.dirname(file) + raw_root = os.path.join(root, 'raw') + web_root = os.path.join(root, 'web') + _, categories, _ = next(os.walk(raw_root)) + sections = {} + for category in categories: + section = { + 'id': category, + 'label': SECTIONS.get(category, category), + } + content = [] + raw_category = os.path.join(raw_root, category) + for directory, directories, files in os.walk(raw_category): + for file in files: + relative = os.path.relpath(directory, raw_root) + name, _ = os.path.splitext(file) + raw_file = os.path.join('raw', relative, file) + web_file = os.path.join('web', relative, f'{name}.mp4') + content.append(card(name, web_file, raw_file)) + section['content'] = os.linesep.join(content) + sections[category] = section + for id, section in sections.items(): + section['content'] = nav(sections, id) + section['content'] + index = os.path.join(root, 'index.html') + with open(index, 'w') as i: + i.write(html(body(sections))) + + +if __name__ == '__main__': + main() From 7f2fbfcfb4810e1f935aa2571196e88c87e776cc Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 10 Jan 2023 23:26:13 +0100 Subject: [PATCH 04/10] sections/sorted --- build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.py b/build.py index f7a0e3f..9fd4ec1 100755 --- a/build.py +++ b/build.py @@ -45,7 +45,7 @@ def nav(sections, active): def body(sections): html = [] - for section in sections.values(): + for _, section in sorted(sections.items()): html.append(f'
') html.append(section['content']) html.append('
') From 89fa3627891cd925e60fef9db5c8da73c07efe13 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 10 Jan 2023 23:33:45 +0100 Subject: [PATCH 05/10] sections/home --- build.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.py b/build.py index 9fd4ec1..eaa48b8 100755 --- a/build.py +++ b/build.py @@ -78,7 +78,9 @@ def main(): raw_root = os.path.join(root, 'raw') web_root = os.path.join(root, 'web') _, categories, _ = next(os.walk(raw_root)) - sections = {} + sections = { + ' ': {'id': 'home', 'label': '⋅', 'content': str()}, + } for category in categories: section = { 'id': category, From 335e229aa5264c65f110f421cc55c14eb8a18f39 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 10 Jan 2023 23:33:54 +0100 Subject: [PATCH 06/10] css/draft --- index.css | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/index.css b/index.css index e69de29..5590861 100644 --- a/index.css +++ b/index.css @@ -0,0 +1,75 @@ +@viewport { +width: device-width; +zoom: 1; +} + +/* +* { border: 1px solid; } +/* +header { background: #800000; } +nav { background: #008000; } +section { background: #000080; } +/**/ + +* { +box-sizing: border-box; +//margin: 0; +//padding: 0; +} + +html { +background: rgb(0,0,0); +color: rgb(160,160,160); +font-family: sans; +} + +body { +margin: 0 auto; +position: relative; +} + +section { +display: none; +min-height: 100vh; +padding: 7em 1vw 1vh 1vw; +position: absolute; +top: 0; +width: 100%; +} +#home,section:target { +display: block; +} + +nav { +display: flex; +flex-wrap: wrap; +} + +a { +text-decoration: none; +} + +nav a { +background: linear-gradient(rgba(64,64,64,1), rgba(64,64,64,0)); +border-color: rgb(128,128,128); +border-radius: .5em; +border-style: solid; +border-width: 1px 1px 0 1px; +#color: rgb(128,128,0); +font-weight: bold; +padding: .25em .5em; +//transition: all .5s; +} +nav a.active { +background: linear-gradient(rgba(128,128,128,1), rgba(128,128,128,0)); +} + +a { +color: rgb(0,192,192); +} +a:hover { +color: rgb(192,0,0); +} +a:visited { +color: rgb(0,160,160); +} From bf31e8a4c96c55a68da7affe79bf0952eb8391a2 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Wed, 11 Jan 2023 09:43:07 +0100 Subject: [PATCH 07/10] video/preload=none --- build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.py b/build.py index eaa48b8..e893f82 100755 --- a/build.py +++ b/build.py @@ -17,7 +17,7 @@ SECTIONS = { def card(name, web, raw): return f'''\
-