Karan Adhikari commited on
Update metadata.py
Browse files
Backend/helper/metadata.py
CHANGED
|
@@ -57,6 +57,7 @@ def format_imdb_images(imdb_id: str) -> dict:
|
|
| 57 |
}
|
| 58 |
|
| 59 |
def extract_default_id(url: str) -> str | None:
|
|
|
|
| 60 |
# IMDb
|
| 61 |
imdb_match = re.search(r'/title/(tt\d+)', url)
|
| 62 |
if imdb_match:
|
|
@@ -310,7 +311,7 @@ async def fetch_tv_metadata(title, season, episode, encoded_string, year=None, q
|
|
| 310 |
ep_details = {}
|
| 311 |
|
| 312 |
return {
|
| 313 |
-
"tmdb_id": tv_details.get("moviedb_id", ""),
|
| 314 |
"imdb_id": imdb_id,
|
| 315 |
"title": tv_details.get("title", title),
|
| 316 |
"year": tv_details.get("releaseDetailed", {}).get("year", 0),
|
|
@@ -403,7 +404,7 @@ async def fetch_movie_metadata(title, encoded_string, year=None, quality=None, d
|
|
| 403 |
movie_details = {}
|
| 404 |
|
| 405 |
return {
|
| 406 |
-
"tmdb_id": movie_details.get("moviedb_id", ""),
|
| 407 |
"imdb_id": imdb_id,
|
| 408 |
"title": movie_details.get("title", title),
|
| 409 |
"year": movie_details.get("releaseDetailed", {}).get("year", 0),
|
|
|
|
| 57 |
}
|
| 58 |
|
| 59 |
def extract_default_id(url: str) -> str | None:
|
| 60 |
+
"""Extract IMDb or TMDb ID from string."""
|
| 61 |
# IMDb
|
| 62 |
imdb_match = re.search(r'/title/(tt\d+)', url)
|
| 63 |
if imdb_match:
|
|
|
|
| 311 |
ep_details = {}
|
| 312 |
|
| 313 |
return {
|
| 314 |
+
"tmdb_id": tv_details.get("moviedb_id") or imdb_id.replace("tt", ""),
|
| 315 |
"imdb_id": imdb_id,
|
| 316 |
"title": tv_details.get("title", title),
|
| 317 |
"year": tv_details.get("releaseDetailed", {}).get("year", 0),
|
|
|
|
| 404 |
movie_details = {}
|
| 405 |
|
| 406 |
return {
|
| 407 |
+
"tmdb_id": movie_details.get("moviedb_id") or imdb_id.replace("tt", ""),
|
| 408 |
"imdb_id": imdb_id,
|
| 409 |
"title": movie_details.get("title", title),
|
| 410 |
"year": movie_details.get("releaseDetailed", {}).get("year", 0),
|