Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
|
@@ -73,24 +73,9 @@ def meta(user_key: str, m_type: str, meta_id: str):
|
|
| 73 |
if not m: return {"meta": {}}
|
| 74 |
|
| 75 |
m.pop("_id", None)
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
if "
|
| 79 |
-
m["cast"] = [str(x) for x in m["cast"] if x]
|
| 80 |
-
else:
|
| 81 |
-
m["cast"] = []
|
| 82 |
-
|
| 83 |
-
if "director" in m and m["director"]:
|
| 84 |
-
m["director"] = [str(x) for x in m["director"] if x]
|
| 85 |
-
else:
|
| 86 |
-
m["director"] = []
|
| 87 |
-
|
| 88 |
-
# imdbRating ကို string အနေနဲ့ သေချာထားပါ
|
| 89 |
-
if "imdbRating" in m and m["imdbRating"]:
|
| 90 |
-
m["imdbRating"] = str(m["imdbRating"])
|
| 91 |
-
|
| 92 |
-
# Debugging အတွက် log ထုတ်ပါ
|
| 93 |
-
print(f"Meta {meta_id} - Cast: {m.get('cast', [])[:3]}, Director: {m.get('director', [])}")
|
| 94 |
|
| 95 |
return {"meta": m}
|
| 96 |
|
|
@@ -112,47 +97,4 @@ def stream(user_key: str, m_type: str, id: str):
|
|
| 112 |
query = {"tmdb_id": parts[1]}
|
| 113 |
if len(parts) == 4: query["season"], query["episode"] = int(parts[2]), int(parts[3])
|
| 114 |
streams = list(streams_col.find(query))
|
| 115 |
-
return {"streams": [{"name": "MyanmarSwe 💎", "url": s["url"]} for s in streams]}
|
| 116 |
-
|
| 117 |
-
# ရှိပြီးသား data တွေကို cast နဲ့ director ပြင်ဆင်ရန် Migration Endpoint (တစ်ခါသုံးရန်)
|
| 118 |
-
@app.post("/fix-existing-data")
|
| 119 |
-
async def fix_existing_data():
|
| 120 |
-
"""ရှိပြီးသား meta data တွေကို cast နဲ့ director ထည့်ပေးမယ်"""
|
| 121 |
-
from sync import get_tmdb_meta
|
| 122 |
-
import time
|
| 123 |
-
|
| 124 |
-
fixed_count = 0
|
| 125 |
-
skipped_count = 0
|
| 126 |
-
|
| 127 |
-
for meta in metas_col.find({"type": {"$in": ["movie", "series"]}}):
|
| 128 |
-
# cast နဲ့ director မရှိတဲ့ ဟာတွေကိုပဲ ပြင်မယ်
|
| 129 |
-
if not meta.get("cast") and not meta.get("director"):
|
| 130 |
-
tmdb_id = meta["id"].replace("tmdb:", "")
|
| 131 |
-
print(f"Fixing: {meta.get('name')} (ID: {tmdb_id})")
|
| 132 |
-
|
| 133 |
-
new_meta = get_tmdb_meta(tmdb_id, meta["type"])
|
| 134 |
-
if new_meta:
|
| 135 |
-
result = metas_col.update_one(
|
| 136 |
-
{"id": meta["id"]},
|
| 137 |
-
{"$set": {
|
| 138 |
-
"cast": new_meta.get("cast", []),
|
| 139 |
-
"director": new_meta.get("director", [])
|
| 140 |
-
}}
|
| 141 |
-
)
|
| 142 |
-
if result.modified_count > 0:
|
| 143 |
-
fixed_count += 1
|
| 144 |
-
print(f"✅ Fixed: {meta.get('name')}")
|
| 145 |
-
else:
|
| 146 |
-
skipped_count += 1
|
| 147 |
-
else:
|
| 148 |
-
skipped_count += 1
|
| 149 |
-
print(f"❌ Failed: {meta.get('name')}")
|
| 150 |
-
|
| 151 |
-
time.sleep(0.1) # TMDB rate limit အတွက် 100ms စောင့်ပါ
|
| 152 |
-
|
| 153 |
-
return {
|
| 154 |
-
"status": "completed",
|
| 155 |
-
"fixed_count": fixed_count,
|
| 156 |
-
"skipped_count": skipped_count,
|
| 157 |
-
"message": f"အောင်မြင်စွာ ပြင်ဆင်ပြီးပါပြီ။ {fixed_count} ခု ပြင်ဆင်နိုင်ခဲ့ပါတယ်။"
|
| 158 |
-
}
|
|
|
|
| 73 |
if not m: return {"meta": {}}
|
| 74 |
|
| 75 |
m.pop("_id", None)
|
| 76 |
+
# Stremio Details တွင် Cast နှင့် Director ပေါ်စေရန် သေချာ Format လုပ်ခြင်း
|
| 77 |
+
if "cast" in m: m["cast"] = [str(x) for x in m["cast"] if x]
|
| 78 |
+
if "director" in m: m["director"] = [str(x) for x in m["director"] if x]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
return {"meta": m}
|
| 81 |
|
|
|
|
| 97 |
query = {"tmdb_id": parts[1]}
|
| 98 |
if len(parts) == 4: query["season"], query["episode"] = int(parts[2]), int(parts[3])
|
| 99 |
streams = list(streams_col.find(query))
|
| 100 |
+
return {"streams": [{"name": "MyanmarSwe 💎", "url": s["url"]} for s in streams]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|