mirror of
https://github.com/g0ldyy/comet.git
synced 2026-01-12 01:16:12 +01:00
feat: Kitsu support
This commit is contained in:
+6
-20
@@ -75,27 +75,13 @@ async def manifest(b64config: str = None):
|
||||
"catalogs": [],
|
||||
"resources": [
|
||||
{
|
||||
"name": "stream",
|
||||
"types": [
|
||||
"movie",
|
||||
"series"
|
||||
],
|
||||
"idPrefixes": [
|
||||
"tt",
|
||||
"kitsu"
|
||||
]
|
||||
"name": "stream",
|
||||
"types": ["movie", "series"],
|
||||
"idPrefixes": ["tt", "kitsu"],
|
||||
}
|
||||
],
|
||||
"types": [
|
||||
"movie",
|
||||
"series",
|
||||
"anime",
|
||||
"other"
|
||||
],
|
||||
"types": ["movie", "series", "anime", "other"],
|
||||
"logo": "https://i.imgur.com/jmVoVMu.jpeg",
|
||||
"background": "https://i.imgur.com/WwnXB3k.jpeg",
|
||||
"behaviorHints": {
|
||||
"configurable": True,
|
||||
"configurationRequired": False
|
||||
}
|
||||
}
|
||||
"behaviorHints": {"configurable": True, "configurationRequired": False},
|
||||
}
|
||||
|
||||
+19
-9
@@ -49,18 +49,26 @@ async def stream(request: Request, b64config: str, type: str, id: str):
|
||||
episode = None
|
||||
if type == "series":
|
||||
info = id.split(":")
|
||||
|
||||
id = info[0]
|
||||
season = int(info[1])
|
||||
episode = int(info[2])
|
||||
|
||||
try:
|
||||
get_metadata = await session.get(
|
||||
f"https://v3.sg.media-imdb.com/suggestion/a/{id}.json"
|
||||
)
|
||||
metadata = await get_metadata.json()
|
||||
|
||||
name = metadata["d"][0 if len(metadata["d"]) == 1 else 1]["l"]
|
||||
kitsu = False
|
||||
if id == "kitsu":
|
||||
kitsu = True
|
||||
get_metadata = await session.get(
|
||||
f"https://kitsu.io/api/edge/anime/{season}"
|
||||
)
|
||||
get_metadata = await get_metadata.json()
|
||||
name = get_metadata["data"]["attributes"]["canonicalTitle"]
|
||||
season = 1
|
||||
else:
|
||||
get_metadata = await session.get(
|
||||
f"https://v3.sg.media-imdb.com/suggestion/a/{id}.json"
|
||||
)
|
||||
metadata = await get_metadata.json()
|
||||
name = metadata["d"][0 if len(metadata["d"]) == 1 else 1]["l"]
|
||||
except Exception as e:
|
||||
logger.warning(f"Exception while getting metadata for {id}: {e}")
|
||||
|
||||
@@ -185,9 +193,10 @@ async def stream(request: Request, b64config: str, type: str, id: str):
|
||||
f"Start of {indexer_manager_type} search for {log_name} with indexers {config['indexers']}"
|
||||
)
|
||||
|
||||
search_terms = [name]
|
||||
search_terms = [name] if not kitsu else [f"{name} {episode}"]
|
||||
if type == "series":
|
||||
search_terms.append(f"{name} S0{season}E0{episode}")
|
||||
if not kitsu:
|
||||
search_terms.append(f"{name} S0{season}E0{episode}")
|
||||
tasks.extend(
|
||||
get_indexer_manager(
|
||||
session, indexer_manager_type, config["indexers"], term
|
||||
@@ -261,6 +270,7 @@ async def stream(request: Request, b64config: str, type: str, id: str):
|
||||
type,
|
||||
season,
|
||||
episode,
|
||||
kitsu,
|
||||
)
|
||||
|
||||
ranked_files = set()
|
||||
|
||||
+15
-10
@@ -44,7 +44,7 @@ class AllDebrid:
|
||||
)
|
||||
|
||||
async def get_files(
|
||||
self, torrent_hashes: list, type: str, season: str, episode: str
|
||||
self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool
|
||||
):
|
||||
chunk_size = 500
|
||||
chunks = [
|
||||
@@ -86,15 +86,20 @@ class AllDebrid:
|
||||
continue
|
||||
|
||||
filename_parsed = parse(filename)
|
||||
if (
|
||||
season in filename_parsed.season
|
||||
and episode in filename_parsed.episode
|
||||
):
|
||||
files[magnet["hash"]] = {
|
||||
"index": magnet["files"].index(file),
|
||||
"title": filename,
|
||||
"size": file["e"][0]["s"] if pack else file["s"],
|
||||
}
|
||||
if episode not in filename_parsed.episode:
|
||||
continue
|
||||
|
||||
if not kitsu and season not in filename_parsed.season:
|
||||
continue
|
||||
|
||||
if kitsu and filename_parsed.season != []:
|
||||
continue
|
||||
|
||||
files[magnet["hash"]] = {
|
||||
"index": magnet["files"].index(file),
|
||||
"title": filename,
|
||||
"size": file["e"][0]["s"] if pack else file["s"],
|
||||
}
|
||||
|
||||
continue
|
||||
|
||||
|
||||
+15
-10
@@ -40,7 +40,7 @@ class DebridLink:
|
||||
)
|
||||
|
||||
async def get_files(
|
||||
self, torrent_hashes: list, type: str, season: str, episode: str
|
||||
self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool
|
||||
):
|
||||
chunk_size = 250
|
||||
chunks = [
|
||||
@@ -76,15 +76,20 @@ class DebridLink:
|
||||
continue
|
||||
|
||||
filename_parsed = parse(filename)
|
||||
if (
|
||||
season in filename_parsed.season
|
||||
and episode in filename_parsed.episode
|
||||
):
|
||||
files[hash] = {
|
||||
"index": hash_files.index(file),
|
||||
"title": filename,
|
||||
"size": file["size"],
|
||||
}
|
||||
if episode not in filename_parsed.episode:
|
||||
continue
|
||||
|
||||
if not kitsu and season not in filename_parsed.season:
|
||||
continue
|
||||
|
||||
if kitsu and filename_parsed.season != []:
|
||||
continue
|
||||
|
||||
files[hash] = {
|
||||
"index": hash_files.index(file),
|
||||
"title": filename,
|
||||
"size": file["size"],
|
||||
}
|
||||
|
||||
continue
|
||||
|
||||
|
||||
+15
-10
@@ -49,7 +49,7 @@ class Premiumize:
|
||||
)
|
||||
|
||||
async def get_files(
|
||||
self, torrent_hashes: list, type: str, season: str, episode: str
|
||||
self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool
|
||||
):
|
||||
chunk_size = 100
|
||||
chunks = [
|
||||
@@ -89,15 +89,20 @@ class Premiumize:
|
||||
filename = filenames[index]
|
||||
if type == "series":
|
||||
filename_parsed = parse(filename)
|
||||
if (
|
||||
season in filename_parsed.season
|
||||
and episode in filename_parsed.episode
|
||||
):
|
||||
files[hashes[index]] = {
|
||||
"index": f"{season}|{episode}",
|
||||
"title": filename,
|
||||
"size": int(filesizes[index]),
|
||||
}
|
||||
if episode not in filename_parsed.episode:
|
||||
continue
|
||||
|
||||
if not kitsu and season not in filename_parsed.season:
|
||||
continue
|
||||
|
||||
if kitsu and filename_parsed.season != []:
|
||||
continue
|
||||
|
||||
files[hashes[index]] = {
|
||||
"index": f"{season}|{episode}",
|
||||
"title": filename,
|
||||
"size": int(filesizes[index]),
|
||||
}
|
||||
|
||||
continue
|
||||
|
||||
|
||||
+16
-11
@@ -41,7 +41,7 @@ class RealDebrid:
|
||||
)
|
||||
|
||||
async def get_files(
|
||||
self, torrent_hashes: list, type: str, season: str, episode: str
|
||||
self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool
|
||||
):
|
||||
chunk_size = 50
|
||||
chunks = [
|
||||
@@ -76,15 +76,20 @@ class RealDebrid:
|
||||
continue
|
||||
|
||||
filename_parsed = parse(filename)
|
||||
if (
|
||||
season in filename_parsed.season
|
||||
and episode in filename_parsed.episode
|
||||
):
|
||||
files[hash] = {
|
||||
"index": index,
|
||||
"title": filename,
|
||||
"size": file["filesize"],
|
||||
}
|
||||
if episode not in filename_parsed.episode:
|
||||
continue
|
||||
|
||||
if not kitsu and season not in filename_parsed.season:
|
||||
continue
|
||||
|
||||
if kitsu and filename_parsed.season != []:
|
||||
continue
|
||||
|
||||
files[hash] = {
|
||||
"index": index,
|
||||
"title": filename,
|
||||
"size": file["filesize"],
|
||||
}
|
||||
|
||||
continue
|
||||
|
||||
@@ -141,7 +146,7 @@ class RealDebrid:
|
||||
for file in get_magnet_info["files"]
|
||||
if is_video(file["path"])
|
||||
)
|
||||
}, # "all" because bad
|
||||
},
|
||||
proxy=self.proxy,
|
||||
)
|
||||
|
||||
|
||||
+15
-10
@@ -41,7 +41,7 @@ class TorBox:
|
||||
)
|
||||
|
||||
async def get_files(
|
||||
self, torrent_hashes: list, type: str, season: str, episode: str
|
||||
self, torrent_hashes: list, type: str, season: str, episode: str, kitsu: bool
|
||||
):
|
||||
chunk_size = 100
|
||||
chunks = [
|
||||
@@ -80,15 +80,20 @@ class TorBox:
|
||||
continue
|
||||
|
||||
filename_parsed = parse(filename)
|
||||
if (
|
||||
season in filename_parsed.season
|
||||
and episode in filename_parsed.episode
|
||||
):
|
||||
files[hash] = {
|
||||
"index": hash_files.index(file),
|
||||
"title": filename,
|
||||
"size": file["size"],
|
||||
}
|
||||
if episode not in filename_parsed.episode:
|
||||
continue
|
||||
|
||||
if not kitsu and season not in filename_parsed.season:
|
||||
continue
|
||||
|
||||
if kitsu and filename_parsed.season != []:
|
||||
continue
|
||||
|
||||
files[hash] = {
|
||||
"index": hash_files.index(file),
|
||||
"title": filename,
|
||||
"size": file["size"],
|
||||
}
|
||||
|
||||
continue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user