home · contact · privacy
To files view, add VideoFile.present filter.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 29 Nov 2024 00:48:37 +0000 (01:48 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 29 Nov 2024 00:48:37 +0000 (01:48 +0100)
src/templates/files.tmpl
src/ytplom/misc.py

index 72f99ac1557ef9d781161c434096113c2e6321b4..0dda3db556192f219dcb91f24b9b36b390694d37 100644 (file)
@@ -4,12 +4,18 @@
 {% block body %}
 {{ macros.nav_head(page_names, "files") }}
 <form method="GET">
-filter: <input name="filter" value="{{filter}}" /><input type="submit" value="filter" />
+filter: <input name="filter" value="{{filter}}" />
+show absent: <input type="checkbox" name="show_absent" {% if show_absent %}checked{% endif %}/>
+<input type="submit" value="filter" />
 </form>
-<p>downloaded videos ({{files|length}}):</p>
-<ul>
+<p>known files (shown: {{files|length}}):</p>
+<table>
+<tr><th>present</th><th>path</th></td>
 {% for file in files %}
-<li><a href="/{{page_names.file}}/{{file.rel_path_b64}}">{{file.rel_path}}</a>
+<tr>
+<td><input type="checkbox"{% if file.present %} checked{% endif %} disabled/></td>
+<td><a href="/{{page_names.file}}/{{file.rel_path_b64}}">{{file.rel_path}}</a></td>
+</tr>
 {% endfor %}
-</ul>
+</table>
 {% endblock %}
index f35a9c8cb89f22c3f2a805880595deff77d5606c..0cd4c92c5f9d34dcc3402213e160859ae3b56ea0 100644 (file)
@@ -857,8 +857,10 @@ class TaskHandler(BaseHTTPRequestHandler):
             elif PAGE_NAMES['download'] == page_name:
                 self._send_or_download_video(YoutubeId(toks_url[2]))
             elif PAGE_NAMES['files'] == page_name:
-                filter_ = ParamsStr(parse_qs(url.query).get('filter', [''])[0])
-                self._send_files_index(filter_)
+                params = parse_qs(url.query)
+                filter_ = ParamsStr(params.get('filter', [''])[0])
+                show_absent = params.get('show_absent', [False])[0]
+                self._send_files_index(filter_, bool(show_absent))
             elif PAGE_NAMES['file'] == page_name:
                 self._send_file_data(B64Str(toks_url[2]))
             elif PAGE_NAMES['yt_result'] == page_name:
@@ -962,13 +964,16 @@ class TaskHandler(BaseHTTPRequestHandler):
                 NAME_TEMPLATE_FILE_DATA,
                 {'file': file, 'flag_names': list(FILE_FLAGS)})
 
-    def _send_files_index(self, filter_: ParamsStr) -> None:
+    def _send_files_index(self, filter_: ParamsStr, show_absent: bool) -> None:
         conn = DbConnection()
-        files = [f for f in VideoFile.get_all(conn) if filter_ in f.rel_path]
+        files = [f for f in VideoFile.get_all(conn)
+                 if (filter_ in f.rel_path) and (show_absent or f.present)]
         conn.commit_close()
         files.sort(key=lambda t: t.rel_path)
-        self._send_rendered_template(NAME_TEMPLATE_FILES,
-                                     {'files': files, 'filter': filter_})
+        self._send_rendered_template(
+                NAME_TEMPLATE_FILES,
+                {'files': files, 'filter': filter_,
+                 'show_absent': show_absent})
 
     def _send_missing_json(self) -> None:
         conn = DbConnection()