From 75aa7a544a79f86a880a0b9e04bfedd65c6f3b85 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Fri, 29 Nov 2024 07:27:09 +0100 Subject: [PATCH] In /files view, also show file sizes. --- src/templates/files.tmpl | 2 ++ src/ytplom/misc.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/templates/files.tmpl b/src/templates/files.tmpl index a44066b..2d58c5b 100644 --- a/src/templates/files.tmpl +++ b/src/templates/files.tmpl @@ -11,8 +11,10 @@ show absent: known files (shown: {{files|length}}):

+ {% for file in files %} + diff --git a/src/ytplom/misc.py b/src/ytplom/misc.py index 2bdb0c3..45d2c40 100644 --- a/src/ytplom/misc.py +++ b/src/ytplom/misc.py @@ -391,6 +391,12 @@ class VideoFile(DbData): """Return self.rel_path suffixed under PATH_DOWNLOADS.""" return PATH_DOWNLOADS.joinpath(self.rel_path) + @property + def size(self) -> float: + if not self.full_path.is_file(): + return -1 + return self.full_path.stat().st_size / (1024 * 1024) + @property def present(self) -> bool: """Return if file exists in filesystem.""" -- 2.30.2
sizeactionspath
{{ file.size | round(3) }} {{file.rel_path}}