From 4f4e5276a66925868ca38d6912d3cd665c7e601c Mon Sep 17 00:00:00 2001 From: David Kifer Date: Sat, 6 Dec 2025 20:47:35 -0500 Subject: [PATCH] Added modifications --- stashtoolkit_webtop/backend/app.py | 72 +++++ stashtoolkit_webtop/files.csv | 1 + stashtoolkit_webtop/instance/local_cache.db | Bin 49152 -> 49152 bytes stashtoolkit_webtop/paths.csv | 1 + stashtoolkit_webtop/requirements.txt | 3 +- stashtoolkit_webtop/scenes.csv | 1 + stashtoolkit_webtop/static/index.html | 331 ++++++++++++-------- 7 files changed, 272 insertions(+), 137 deletions(-) create mode 100644 stashtoolkit_webtop/files.csv create mode 100644 stashtoolkit_webtop/paths.csv create mode 100644 stashtoolkit_webtop/scenes.csv diff --git a/stashtoolkit_webtop/backend/app.py b/stashtoolkit_webtop/backend/app.py index 0020910..8d81baa 100644 --- a/stashtoolkit_webtop/backend/app.py +++ b/stashtoolkit_webtop/backend/app.py @@ -728,6 +728,7 @@ def qb_torrents(): "dlspeed": torrent.dlspeed, "upspeed": torrent.upspeed, "eta": torrent.eta, + "save_path": torrent.save_path }) return jsonify(torrents) except Exception as e: @@ -753,6 +754,10 @@ def qb_action(): client.torrents_resume(torrent_hashes=hashes) elif action == 'delete': client.torrents_delete(delete_files=True, torrent_hashes=hashes) + elif action == 'force_resume': + client.torrents_force_resume(torrent_hashes=hashes) + elif action == 'recheck': + client.torrents_recheck(torrent_hashes=hashes) else: return jsonify({"error": "Invalid action."}), 400 @@ -760,5 +765,72 @@ def qb_action(): except Exception as e: return jsonify({"error": str(e)}), 500 +@app.route('/api/create_folder', methods=['POST']) +def create_folder(): + data = request.get_json() + path = data.get('path') + folder_name = data.get('folder_name') + + if not path or not folder_name: + return jsonify({"error": "Path and folder name are required"}), 400 + + try: + creds = get_smb_credentials(path) + # Security check: Ensure destination is within the main VIDEO_PATH + common_path = os.path.commonpath([os.path.normpath(VIDEO_PATH), os.path.normpath(path)]) + if common_path != os.path.normpath(VIDEO_PATH): + raise ValueError("Creation path is outside the allowed base directory.") + + new_folder_path = os.path.join(path, folder_name) + smbclient.makedirs(new_folder_path, exist_ok=False, **creds) + return jsonify({"success": True}) + except Exception as e: + return jsonify({"error": str(e)}), 500 + +@app.route('/api/move_file', methods=['POST']) +def move_file(): + data = request.get_json() + source_path = data.get('source_path') + dest_path = data.get('dest_path') + + if not source_path or not dest_path: + return jsonify({"error": "Source and destination paths are required"}), 400 + + try: + creds = get_smb_credentials(source_path) + # Ensure the destination directory exists + if not smbclient.exists(dest_path, **creds): + smbclient.makedirs(dest_path, exist_ok=True, **creds) + + # Construct the full destination path including the filename + filename = os.path.basename(source_path) + full_dest_path = os.path.join(dest_path, filename) + + smbclient.rename(source_path, full_dest_path, **creds) + return jsonify({"success": True}) + except Exception as e: + return jsonify({"error": str(e)}), 500 + +@app.route('/api/qb_set_location', methods=['POST']) +def qb_set_location(): + try: + client = get_qb_client() + if not client: + return jsonify({"error": "qBittorrent not configured."}), 400 + + data = request.get_json() + hashes = data.get('hashes') + location = data.get('location') + + if not hashes or not location: + return jsonify({"error": "Missing hashes or location."}), 400 + + client.torrents_set_location(torrent_hashes=hashes, location=location) + return jsonify({"success": True}) + except Exception as e: + return jsonify({"error": str(e)}), 500 + if __name__ == '__main__': app.run(debug=True, port=5000, host='0.0.0.0') + + diff --git a/stashtoolkit_webtop/files.csv b/stashtoolkit_webtop/files.csv new file mode 100644 index 0000000..95936b5 --- /dev/null +++ b/stashtoolkit_webtop/files.csv @@ -0,0 +1 @@ +scene_id,path,basename,path_id diff --git a/stashtoolkit_webtop/instance/local_cache.db b/stashtoolkit_webtop/instance/local_cache.db index 059e88251ca3a9b30e17b27b590637af237683ad..82456da3a93bc18202bd4cc6fefefcc8c7cbec67 100644 GIT binary patch delta 48 wcmZo@U~Xt&o**swn}LCW2Z&+d;Y1x{#@`zg+Ibn-C%@p`!N|6GAz%DP02Sg4{Qv*} delta 48 wcmZo@U~Xt&o**rFk%57M2Z&){`$QdM#)}&h+Ibn-Ccog_!N|UOAz%DP00_Jce*gdg diff --git a/stashtoolkit_webtop/paths.csv b/stashtoolkit_webtop/paths.csv new file mode 100644 index 0000000..11d6eea --- /dev/null +++ b/stashtoolkit_webtop/paths.csv @@ -0,0 +1 @@ +id,path diff --git a/stashtoolkit_webtop/requirements.txt b/stashtoolkit_webtop/requirements.txt index 4fa9707..fd39ecf 100644 --- a/stashtoolkit_webtop/requirements.txt +++ b/stashtoolkit_webtop/requirements.txt @@ -2,4 +2,5 @@ flask[async] smbprotocol qbittorrent-api requests -beautifulsoup4 \ No newline at end of file +beautifulsoup4 +pandas \ No newline at end of file diff --git a/stashtoolkit_webtop/scenes.csv b/stashtoolkit_webtop/scenes.csv new file mode 100644 index 0000000..8e36290 --- /dev/null +++ b/stashtoolkit_webtop/scenes.csv @@ -0,0 +1 @@ +id,oshash diff --git a/stashtoolkit_webtop/static/index.html b/stashtoolkit_webtop/static/index.html index 5099ad9..79dc82e 100644 --- a/stashtoolkit_webtop/static/index.html +++ b/stashtoolkit_webtop/static/index.html @@ -134,8 +134,6 @@

Your friendly neighborhood media manager

-
-
@@ -348,31 +346,31 @@
-

+

- + -

+ -
+
-
+
-
+
-

+

-
+
-
+
-
+
-
+
@@ -448,7 +446,7 @@ - +
@@ -594,25 +592,29 @@
-

+
- -
+ -
+
-
+
- + - + + + + + @@ -656,6 +658,10 @@ + +
+
+