Spaces:
Paused
Paused
Update engine.py
Browse files
engine.py
CHANGED
|
@@ -7,8 +7,8 @@ import warnings, requests, queue, re
|
|
| 7 |
import libtorrent as lt
|
| 8 |
from flask import Flask, request, Response, stream_with_context, render_template_string, redirect, url_for, abort
|
| 9 |
|
| 10 |
-
# ⚡ ADDED
|
| 11 |
-
from huggingface_hub import HfApi, CommitOperationAdd
|
| 12 |
|
| 13 |
# --- SILENCE WARNINGS ---
|
| 14 |
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
|
@@ -73,7 +73,7 @@ def fetch_cinemeta(u_id):
|
|
| 73 |
return meta
|
| 74 |
|
| 75 |
# ==========================================
|
| 76 |
-
# FRONT-END DASHBOARD (SMART FOLDERS)
|
| 77 |
# ==========================================
|
| 78 |
DASHBOARD_HTML = """
|
| 79 |
<!DOCTYPE html>
|
|
@@ -161,15 +161,21 @@ DASHBOARD_HTML = """
|
|
| 161 |
<div class="space-y-4">
|
| 162 |
{% for imdb, show in grouped_vault.items() %}
|
| 163 |
<div class="bg-slate-900 rounded-xl border border-slate-700 overflow-hidden shadow-lg">
|
| 164 |
-
|
| 165 |
-
|
|
|
|
| 166 |
<img src="{{ show.poster }}" class="w-12 h-16 object-cover rounded shadow-md border border-slate-600">
|
| 167 |
<div>
|
| 168 |
<h3 class="text-lg font-bold text-blue-300">{{ show.title }}</h3>
|
| 169 |
<p class="text-xs text-slate-400 mt-1 font-mono">📁 {{ show.episodes|length }} Vaulted Items</p>
|
| 170 |
</div>
|
| 171 |
</div>
|
| 172 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
</div>
|
| 174 |
|
| 175 |
<div id="group-{{ imdb }}" class="hidden p-4 bg-slate-900/50">
|
|
@@ -751,5 +757,28 @@ def delete_vaulted(u_id):
|
|
| 751 |
except: pass
|
| 752 |
return redirect(url_for('dashboard', key=ADMIN_KEY))
|
| 753 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 754 |
if __name__ == "__main__":
|
| 755 |
app.run(host="0.0.0.0", port=7860)
|
|
|
|
| 7 |
import libtorrent as lt
|
| 8 |
from flask import Flask, request, Response, stream_with_context, render_template_string, redirect, url_for, abort
|
| 9 |
|
| 10 |
+
# ⚡ ADDED CommitOperationDelete FOR THE 1-CLICK SHOW WIPER
|
| 11 |
+
from huggingface_hub import HfApi, CommitOperationAdd, CommitOperationDelete
|
| 12 |
|
| 13 |
# --- SILENCE WARNINGS ---
|
| 14 |
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
|
|
|
| 73 |
return meta
|
| 74 |
|
| 75 |
# ==========================================
|
| 76 |
+
# FRONT-END DASHBOARD (SMART FOLDERS + BULK DELETE)
|
| 77 |
# ==========================================
|
| 78 |
DASHBOARD_HTML = """
|
| 79 |
<!DOCTYPE html>
|
|
|
|
| 161 |
<div class="space-y-4">
|
| 162 |
{% for imdb, show in grouped_vault.items() %}
|
| 163 |
<div class="bg-slate-900 rounded-xl border border-slate-700 overflow-hidden shadow-lg">
|
| 164 |
+
|
| 165 |
+
<div class="p-4 bg-slate-800 border-b border-slate-700 flex justify-between items-center transition">
|
| 166 |
+
<div class="flex items-center gap-4 cursor-pointer flex-1" onclick="document.getElementById('group-{{ imdb }}').classList.toggle('hidden')">
|
| 167 |
<img src="{{ show.poster }}" class="w-12 h-16 object-cover rounded shadow-md border border-slate-600">
|
| 168 |
<div>
|
| 169 |
<h3 class="text-lg font-bold text-blue-300">{{ show.title }}</h3>
|
| 170 |
<p class="text-xs text-slate-400 mt-1 font-mono">📁 {{ show.episodes|length }} Vaulted Items</p>
|
| 171 |
</div>
|
| 172 |
</div>
|
| 173 |
+
<div class="flex items-center gap-4">
|
| 174 |
+
<span class="text-slate-500 text-xs font-bold cursor-pointer hidden md:block" onclick="document.getElementById('group-{{ imdb }}').classList.toggle('hidden')">EXPAND ▼</span>
|
| 175 |
+
<form action="/delete_show/{{ imdb }}?key={{ key }}" method="POST" onsubmit="return confirm('Are you sure you want to delete ALL vaulted episodes of {{ show.title }}?');">
|
| 176 |
+
<button class="bg-red-500/20 text-red-500 hover:bg-red-500 hover:text-white px-3 py-1.5 rounded text-[10px] uppercase font-bold border border-red-700 transition-colors">DELETE SHOW</button>
|
| 177 |
+
</form>
|
| 178 |
+
</div>
|
| 179 |
</div>
|
| 180 |
|
| 181 |
<div id="group-{{ imdb }}" class="hidden p-4 bg-slate-900/50">
|
|
|
|
| 757 |
except: pass
|
| 758 |
return redirect(url_for('dashboard', key=ADMIN_KEY))
|
| 759 |
|
| 760 |
+
# ⚡ ADDED: BULK DELETE ROUTE FOR ENTIRE SHOWS
|
| 761 |
+
@app.route('/delete_show/<imdb_id>', methods=['POST'])
|
| 762 |
+
def delete_show(imdb_id):
|
| 763 |
+
check_auth()
|
| 764 |
+
try:
|
| 765 |
+
files = api.list_repo_files(repo_id=REPO_ID, repo_type="dataset", token=TOKEN)
|
| 766 |
+
# Find every single file that belongs to this IMDb ID
|
| 767 |
+
ops = [CommitOperationDelete(path_in_repo=f) for f in files if f.startswith(f"{imdb_id}_")]
|
| 768 |
+
|
| 769 |
+
if ops:
|
| 770 |
+
# Delete all of them in ONE single commit!
|
| 771 |
+
api.create_commit(
|
| 772 |
+
repo_id=REPO_ID,
|
| 773 |
+
repo_type="dataset",
|
| 774 |
+
operations=ops,
|
| 775 |
+
commit_message=f"Bulk delete show {imdb_id}",
|
| 776 |
+
token=TOKEN
|
| 777 |
+
)
|
| 778 |
+
except Exception as e:
|
| 779 |
+
print(f"[API ERROR] Bulk delete failed: {e}", flush=True)
|
| 780 |
+
|
| 781 |
+
return redirect(url_for('dashboard', key=ADMIN_KEY))
|
| 782 |
+
|
| 783 |
if __name__ == "__main__":
|
| 784 |
app.run(host="0.0.0.0", port=7860)
|