From: Christian Heller Date: Fri, 29 Nov 2024 06:27:09 +0000 (+0100) Subject: In /files view, also show file sizes. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%22https:/validator.w3.org/day?a=commitdiff_plain;h=75aa7a544a79f86a880a0b9e04bfedd65c6f3b85;p=ytplom In /files view, also show file sizes. --- 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."""
sizeactionspath
{{ file.size | round(3) }} {{file.rel_path}}