home · contact · privacy
In /files view, also show file sizes.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 29 Nov 2024 06:27:09 +0000 (07:27 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 29 Nov 2024 06:27:09 +0000 (07:27 +0100)
src/templates/files.tmpl
src/ytplom/misc.py

index a44066b5c733cb31df98ee1db77907abf55dc0ac..2d58c5b63f3302b78a6f73cb14c3aae52c03fa1c 100644 (file)
@@ -11,8 +11,10 @@ show absent: <input type="checkbox" name="show_absent" {% if show_absent %}check
 <p>known files (shown: {{files|length}}):</p>
 <form action="files" method="POST">
 <table>
+<tr><th>size</th><th>actions</th><th>path</th></tr>
 {% for file in files %}
 <tr>
+<td>{{ file.size | round(3) }}</td>
 <td><input type="submit" name="play_{{file.rel_path_b64}}" value="play" {% if not file.present %}disabled {% endif %}/></td>
 <td><a href="/{{page_names.file}}/{{file.rel_path_b64}}">{{file.rel_path}}</a></td>
 </tr>
index 2bdb0c3a716b76e8c4e04d29be18634701d35493..45d2c408391b1ada0835bab0cfa580fd6e9920ea 100644 (file)
@@ -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."""