home · contact · privacy
Add inject-and-jump-to-playing buttons. master
authorChristian Heller <c.heller@plomlompom.de>
Fri, 28 Feb 2025 16:36:58 +0000 (17:36 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 28 Feb 2025 16:36:58 +0000 (17:36 +0100)
src/templates/file_data.tmpl
src/templates/files.tmpl
src/ytplom/http.py

index 0b069fa4cf463ee2eaabac56c57545682ae6a91e..e1247a32e87e243a790e0f4900f26c07d355a64a 100644 (file)
@@ -31,6 +31,7 @@ async function update_file_data() {
         add_a_to(td_present, "yes", "/{{page_names.download}}/{{file.yt_id}}");
         add_text_to(td_present, " ");
         add_player_btn_to(td_present, 'add as next', `inject_${file_data.digest}`);
         add_a_to(td_present, "yes", "/{{page_names.download}}/{{file.yt_id}}");
         add_text_to(td_present, " ");
         add_player_btn_to(td_present, 'add as next', `inject_${file_data.digest}`);
+        add_player_btn_to(td_present, 'add and play', `injectplay_${file_data.digest}`);
     } else {
         td_present.textContent = "no";
     }
     } else {
         td_present.textContent = "no";
     }
index 8909d89cba9a61069b8ea0359a638142a8c3a889..cf258a68564060fae5e2f65be2c904f6c11db858 100644 (file)
@@ -68,6 +68,7 @@ function populate_list_item_row(tr, file) {
     add_child_to('td', tr, {textContent: file.duration});
     const td_inject = add_child_to('td', tr);
     add_player_btn_to(td_inject, 'add as next', `inject_${file.digest}`, !file.present)
     add_child_to('td', tr, {textContent: file.duration});
     const td_inject = add_child_to('td', tr);
     add_player_btn_to(td_inject, 'add as next', `inject_${file.digest}`, !file.present)
+    add_player_btn_to(td_inject, 'add as play', `injectplay_${file.digest}`, !file.present)
     add_tag_links_to(add_child_to('td', tr), file.tags_showable);
     add_a_to(add_child_to('td', tr), file.rel_path, `${PATH_PREFIX_FILE}${file.digest}`);
 }
     add_tag_links_to(add_child_to('td', tr), file.tags_showable);
     add_a_to(add_child_to('td', tr), file.rel_path, `${PATH_PREFIX_FILE}${file.digest}`);
 }
index 0e42e673041ee94a25b65307e45850a2b0c8c791..3785b0719ea39685abe1c184a52000ef8c319e35 100644 (file)
@@ -167,11 +167,13 @@ class _TaskHandler(PlomHttpHandler):
             self.server.player.move_entry(int(command.split('_')[1]), False)
         elif command.startswith('rm_'):
             self.server.player.remove_by_idx(int(command.split('_')[1]))
             self.server.player.move_entry(int(command.split('_')[1]), False)
         elif command.startswith('rm_'):
             self.server.player.remove_by_idx(int(command.split('_')[1]))
-        elif command.startswith('inject_'):
+        elif command.startswith('inject_') or command.startswith('injectplay_'):
+            command, digest = command.split('_', 1)
             with DbConn() as conn:
             with DbConn() as conn:
-                file = VideoFile.get_one(
-                        conn, Hash.from_b64(command.split('_', 1)[1]))
+                file = VideoFile.get_one(conn, Hash.from_b64(digest))
             self.server.player.inject(file)
             self.server.player.inject(file)
+            if 'injectplay' == command:
+                self.server.player.next()
         self.send_http(b'OK')
 
     def _purge_deleted_files(self) -> None:
         self.send_http(b'OK')
 
     def _purge_deleted_files(self) -> None: