Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
|
@@ -28,15 +28,14 @@ def manifest(user_key: str):
|
|
| 28 |
valid = is_user_valid(user_key)
|
| 29 |
return {
|
| 30 |
"id": "com.myanmarswe.pro",
|
| 31 |
-
"version": "2.9.
|
| 32 |
"name": f"MSwe Cinema {'💎' if valid else '⚠️'}",
|
| 33 |
"resources": ["catalog", "meta", "stream"],
|
| 34 |
"types": ["movie", "series"],
|
| 35 |
-
"idPrefixes": ["tmdb:"
|
| 36 |
"catalogs": [
|
| 37 |
{"type": "movie", "id": "mswe_m", "name": "Latest Movies", "extra": [{"name": "search"}, {"name": "genre", "options": MOVIE_GENRES}]},
|
| 38 |
-
{"type": "series", "id": "mswe_s", "name": "Latest TV Shows", "extra": [{"name": "search"}, {"name": "genre", "options": SERIES_GENRES}]}
|
| 39 |
-
{"type": "series", "id": "mswe_col", "name": "Collections"}
|
| 40 |
]
|
| 41 |
}
|
| 42 |
|
|
@@ -45,13 +44,7 @@ def manifest(user_key: str):
|
|
| 45 |
def catalog(user_key: str, m_type: str, cat_id: str, extra: str = None):
|
| 46 |
if not is_user_valid(user_key): return {"metas": []}
|
| 47 |
|
| 48 |
-
query = {}
|
| 49 |
-
if cat_id == "mswe_col":
|
| 50 |
-
query["id"] = {"$regex": "^tmdb_col:"}
|
| 51 |
-
else:
|
| 52 |
-
query["type"] = m_type
|
| 53 |
-
if "id" not in query: query["id"] = {"$regex": "^tmdb:"}
|
| 54 |
-
|
| 55 |
if extra:
|
| 56 |
params = dict(x.split('=') for x in extra.split('&') if '=' in x)
|
| 57 |
if "search" in params: query["name"] = {"$regex": params["search"], "$options": "i"}
|
|
@@ -60,7 +53,7 @@ def catalog(user_key: str, m_type: str, cat_id: str, extra: str = None):
|
|
| 60 |
cursor = metas_col.find(query).sort("updated_at", DESCENDING).limit(60)
|
| 61 |
|
| 62 |
return {"metas": [{
|
| 63 |
-
"id": m["id"], "type": m
|
| 64 |
"poster": m["poster"], "logo": m.get("logo"), "description": m.get("description"),
|
| 65 |
"genres": m.get("genres", []), "releaseInfo": str(m.get("releaseInfo", "")),
|
| 66 |
"imdbRating": m.get("imdbRating")
|
|
@@ -73,30 +66,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 |
-
|
| 79 |
-
if "cast" in m:
|
| 80 |
-
# None values ကို filter လုပ်ပြီး string အဖြစ် သေချာပြောင်း
|
| 81 |
-
m["cast"] = [str(c) for c in m["cast"] if c and str(c).strip()]
|
| 82 |
-
else:
|
| 83 |
-
m["cast"] = []
|
| 84 |
-
|
| 85 |
-
if "director" in m:
|
| 86 |
-
m["director"] = [str(d) for d in m["director"] if d and str(d).strip()]
|
| 87 |
-
else:
|
| 88 |
-
m["director"] = []
|
| 89 |
-
|
| 90 |
-
# ✅ Custom overview အတွက် description ကို သေချာပေးခြင်း
|
| 91 |
-
if "description" not in m or not m["description"]:
|
| 92 |
-
m["description"] = "No description available."
|
| 93 |
-
|
| 94 |
-
# ✅ Runtime ကို သေချာ format လုပ်ခြင်း
|
| 95 |
-
if "runtime" in m and m["runtime"]:
|
| 96 |
-
if isinstance(m["runtime"], int):
|
| 97 |
-
m["runtime"] = f"{m['runtime']} min"
|
| 98 |
-
else:
|
| 99 |
-
m["runtime"] = None
|
| 100 |
|
| 101 |
return {"meta": m}
|
| 102 |
|
|
@@ -105,19 +77,9 @@ def stream(user_key: str, m_type: str, id: str):
|
|
| 105 |
if not is_user_valid(user_key): return {"streams": []}
|
| 106 |
|
| 107 |
parts = id.split(":")
|
| 108 |
-
# Collection streams logic
|
| 109 |
-
if id.startswith("tmdb_col:"):
|
| 110 |
-
col_meta = metas_col.find_one({"id": f"tmdb_col:{parts[1]}"})
|
| 111 |
-
if col_meta and "videos" in col_meta:
|
| 112 |
-
target = next((v for v in col_meta["videos"] if v["season"] == int(parts[2]) and v["episode"] == int(parts[3])), None)
|
| 113 |
-
if target:
|
| 114 |
-
streams = list(streams_col.find({"tmdb_id": str(target["movie_id"])}))
|
| 115 |
-
return {"streams": [{"name": "MyanmarSwe 💎", "url": s["url"]} for s in streams]}
|
| 116 |
-
|
| 117 |
-
# Regular streams logic
|
| 118 |
query = {"tmdb_id": parts[1]}
|
| 119 |
if len(parts) == 4:
|
| 120 |
-
query["season"] = int(parts[2])
|
| 121 |
-
|
| 122 |
streams = list(streams_col.find(query))
|
| 123 |
return {"streams": [{"name": "MyanmarSwe 💎", "url": s["url"]} for s in streams]}
|
|
|
|
| 28 |
valid = is_user_valid(user_key)
|
| 29 |
return {
|
| 30 |
"id": "com.myanmarswe.pro",
|
| 31 |
+
"version": "2.9.1",
|
| 32 |
"name": f"MSwe Cinema {'💎' if valid else '⚠️'}",
|
| 33 |
"resources": ["catalog", "meta", "stream"],
|
| 34 |
"types": ["movie", "series"],
|
| 35 |
+
"idPrefixes": ["tmdb:"],
|
| 36 |
"catalogs": [
|
| 37 |
{"type": "movie", "id": "mswe_m", "name": "Latest Movies", "extra": [{"name": "search"}, {"name": "genre", "options": MOVIE_GENRES}]},
|
| 38 |
+
{"type": "series", "id": "mswe_s", "name": "Latest TV Shows", "extra": [{"name": "search"}, {"name": "genre", "options": SERIES_GENRES}]}
|
|
|
|
| 39 |
]
|
| 40 |
}
|
| 41 |
|
|
|
|
| 44 |
def catalog(user_key: str, m_type: str, cat_id: str, extra: str = None):
|
| 45 |
if not is_user_valid(user_key): return {"metas": []}
|
| 46 |
|
| 47 |
+
query = {"type": m_type}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
if extra:
|
| 49 |
params = dict(x.split('=') for x in extra.split('&') if '=' in x)
|
| 50 |
if "search" in params: query["name"] = {"$regex": params["search"], "$options": "i"}
|
|
|
|
| 53 |
cursor = metas_col.find(query).sort("updated_at", DESCENDING).limit(60)
|
| 54 |
|
| 55 |
return {"metas": [{
|
| 56 |
+
"id": m["id"], "type": m["type"], "name": m["name"],
|
| 57 |
"poster": m["poster"], "logo": m.get("logo"), "description": m.get("description"),
|
| 58 |
"genres": m.get("genres", []), "releaseInfo": str(m.get("releaseInfo", "")),
|
| 59 |
"imdbRating": m.get("imdbRating")
|
|
|
|
| 66 |
if not m: return {"meta": {}}
|
| 67 |
|
| 68 |
m.pop("_id", None)
|
| 69 |
+
# Cast နှင့် Director List ကို Stremio မှ ဖတ်နိုင်သော Array string အဖြစ် သေချာအောင်လုပ်ခြင်း
|
| 70 |
+
if "cast" in m: m["cast"] = [str(x) for x in m["cast"] if x]
|
| 71 |
+
if "director" in m: m["director"] = [str(x) for x in m["director"] if x]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
return {"meta": m}
|
| 74 |
|
|
|
|
| 77 |
if not is_user_valid(user_key): return {"streams": []}
|
| 78 |
|
| 79 |
parts = id.split(":")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
query = {"tmdb_id": parts[1]}
|
| 81 |
if len(parts) == 4:
|
| 82 |
+
query["season"], query["episode"] = int(parts[2]), int(parts[3])
|
| 83 |
+
|
| 84 |
streams = list(streams_col.find(query))
|
| 85 |
return {"streams": [{"name": "MyanmarSwe 💎", "url": s["url"]} for s in streams]}
|