mirror of
https://github.com/g0ldyy/comet.git
synced 2026-01-12 01:16:12 +01:00
feat: remove the sketchy one
This commit is contained in:
+1
-5
@@ -147,7 +147,7 @@ async def stream(
|
||||
config["debridApiKey"] = settings.PROXY_DEBRID_STREAM_DEBRID_DEFAULT_APIKEY
|
||||
|
||||
if config["debridApiKey"] == "":
|
||||
services = ["realdebrid", "alldebrid", "premiumize", "torbox", "debridlink", "easydebrid"]
|
||||
services = ["realdebrid", "alldebrid", "premiumize", "torbox", "debridlink"]
|
||||
debrid_emoji = "⬇️"
|
||||
else:
|
||||
services = [config["debridService"]]
|
||||
@@ -462,10 +462,6 @@ async def stream(
|
||||
torrent_size = torrents_by_hash[hash]["Size"]
|
||||
sorted_ranked_files[hash]["data"]["size"] = (
|
||||
files[hash]["size"]
|
||||
if config["debridService"] != "easydebrid"
|
||||
else torrent_size
|
||||
if torrent_size
|
||||
else 0
|
||||
)
|
||||
sorted_ranked_files[hash]["data"]["torrent_size"] = (
|
||||
torrent_size if torrent_size else files[hash]["size"]
|
||||
|
||||
@@ -1,184 +0,0 @@
|
||||
import aiohttp
|
||||
import asyncio
|
||||
|
||||
from RTN import parse
|
||||
|
||||
from comet.utils.general import is_video
|
||||
from comet.utils.logger import logger
|
||||
|
||||
|
||||
class EasyDebrid:
|
||||
def __init__(self, session: aiohttp.ClientSession, debrid_api_key: str, ip: str):
|
||||
self.session = session
|
||||
self.ip = ip
|
||||
self.proxy = None
|
||||
|
||||
self.api_url = "https://easydebrid.com/api/v1"
|
||||
self.headers = {"Authorization": f"Bearer {debrid_api_key}"}
|
||||
|
||||
if ip:
|
||||
self.headers["X-Forwarded-For"] = ip
|
||||
|
||||
async def check_premium(self):
|
||||
try:
|
||||
response = await self.session.get(
|
||||
f"{self.api_url}/user/details", headers=self.headers
|
||||
)
|
||||
data = await response.json()
|
||||
return bool(data["paid_until"])
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to check EasyDebrid premium status: {e}")
|
||||
|
||||
return False
|
||||
|
||||
async def get_instant(self, chunk):
|
||||
try:
|
||||
response = await self.session.post(
|
||||
f"{self.api_url}/link/lookup",
|
||||
json={"urls": chunk},
|
||||
headers=self.headers,
|
||||
)
|
||||
data = await response.json()
|
||||
|
||||
if not data or "cached" not in data:
|
||||
return None
|
||||
|
||||
return {
|
||||
"status": "success",
|
||||
"response": data["cached"],
|
||||
"filename": data.get("filenames", []),
|
||||
"filesize": [None] * len(chunk),
|
||||
"hashes": chunk,
|
||||
}
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
f"Exception while checking hash instant availability on EasyDebrid: {e}"
|
||||
)
|
||||
|
||||
async def get_files(self, torrent_hashes, type, season, episode, kitsu):
|
||||
chunk_size = 100
|
||||
chunks = [
|
||||
torrent_hashes[i : i + chunk_size]
|
||||
for i in range(0, len(torrent_hashes), chunk_size)
|
||||
]
|
||||
|
||||
tasks = []
|
||||
for chunk in chunks:
|
||||
tasks.append(self.get_instant(chunk))
|
||||
|
||||
responses = await asyncio.gather(*tasks)
|
||||
|
||||
files = {}
|
||||
|
||||
if type == "series":
|
||||
for result in responses:
|
||||
if result["status"] != "success":
|
||||
continue
|
||||
|
||||
responses = result["response"]
|
||||
filenames = result["filename"]
|
||||
hashes = result["hashes"]
|
||||
|
||||
for index, (is_cached, hash) in enumerate(zip(responses, hashes)):
|
||||
if not is_cached:
|
||||
continue
|
||||
|
||||
try:
|
||||
hash_files = filenames[index]
|
||||
except:
|
||||
hash_files = filenames[str(index)]
|
||||
|
||||
for filename in hash_files:
|
||||
if not is_video(filename):
|
||||
continue
|
||||
|
||||
if "sample" in filename.lower():
|
||||
continue
|
||||
|
||||
filename_parsed = parse(filename)
|
||||
if not filename_parsed:
|
||||
continue
|
||||
|
||||
if episode not in filename_parsed.episodes:
|
||||
continue
|
||||
|
||||
if kitsu:
|
||||
if filename_parsed.seasons:
|
||||
continue
|
||||
elif season not in filename_parsed.seasons:
|
||||
continue
|
||||
|
||||
files[hash] = {
|
||||
"index": f"{season}|{episode}",
|
||||
"title": filename,
|
||||
"size": 0, # Size not available in lookup response
|
||||
}
|
||||
break # Found matching video file
|
||||
else:
|
||||
for result in responses:
|
||||
if result["status"] != "success":
|
||||
continue
|
||||
|
||||
responses = result["response"]
|
||||
filenames = result["filename"]
|
||||
hashes = result["hashes"]
|
||||
|
||||
for index, (is_cached, hash) in enumerate(zip(responses, hashes)):
|
||||
if not is_cached:
|
||||
continue
|
||||
|
||||
try:
|
||||
hash_files = filenames[index]
|
||||
except:
|
||||
hash_files = filenames[str(index)]
|
||||
|
||||
video_files = [f for f in hash_files if is_video(f)]
|
||||
if not video_files:
|
||||
continue
|
||||
|
||||
# Use first valid video file found
|
||||
files[hash] = {
|
||||
"index": 0,
|
||||
"title": video_files[0],
|
||||
"size": 0, # Size not available in lookup response
|
||||
}
|
||||
|
||||
return files
|
||||
|
||||
async def generate_download_link(self, hash, index):
|
||||
try:
|
||||
response = await self.session.post(
|
||||
f"{self.api_url}/link/generate",
|
||||
headers={**self.headers, "Content-Type": "application/json"},
|
||||
json={"url": f"magnet:?xt=urn:btih:{hash}"},
|
||||
)
|
||||
data = await response.json()
|
||||
|
||||
if not data or "files" not in data:
|
||||
return None
|
||||
|
||||
video_files = [
|
||||
f
|
||||
for f in data["files"]
|
||||
if is_video(f["filename"]) and "sample" not in f["filename"].lower()
|
||||
]
|
||||
|
||||
if not video_files:
|
||||
return None
|
||||
|
||||
if "|" in str(index):
|
||||
season, episode = map(int, index.split("|"))
|
||||
for file in video_files:
|
||||
parsed = parse(file["filename"])
|
||||
if (
|
||||
parsed
|
||||
and season in parsed.seasons
|
||||
and episode in parsed.episodes
|
||||
):
|
||||
return file["url"]
|
||||
|
||||
largest_file = max(video_files, key=lambda x: x["size"])
|
||||
|
||||
return largest_file["url"]
|
||||
except Exception as e:
|
||||
logger.warning(f"Error generating link for {hash}|{index}: {e}")
|
||||
@@ -5,7 +5,6 @@ from .alldebrid import AllDebrid
|
||||
from .premiumize import Premiumize
|
||||
from .torbox import TorBox
|
||||
from .debridlink import DebridLink
|
||||
from .easydebrid import EasyDebrid
|
||||
|
||||
|
||||
def getDebrid(session: aiohttp.ClientSession, config: dict, ip: str):
|
||||
@@ -20,6 +19,4 @@ def getDebrid(session: aiohttp.ClientSession, config: dict, ip: str):
|
||||
elif debrid_service == "torbox":
|
||||
return TorBox(session, debrid_api_key)
|
||||
elif debrid_service == "debridlink":
|
||||
return DebridLink(session, debrid_api_key)
|
||||
elif debrid_service == "easydebrid":
|
||||
return EasyDebrid(session, debrid_api_key, ip)
|
||||
return DebridLink(session, debrid_api_key)
|
||||
@@ -542,7 +542,6 @@
|
||||
<div class="form-item">
|
||||
<sl-select id="debridService" value="torbox" label="Debrid Service" placeholder="Select debrid service">
|
||||
<sl-option value="torbox">TorBox</sl-option>
|
||||
<sl-option value="easydebrid">EasyDebrid</sl-option>
|
||||
<sl-option value="debridlink">Debrid-Link</sl-option>
|
||||
<sl-option value="alldebrid">All-Debrid</sl-option>
|
||||
<sl-option value="premiumize">Premiumize</sl-option>
|
||||
@@ -554,8 +553,6 @@
|
||||
<label for="debridService">
|
||||
Debrid API Key -
|
||||
<a id="apiKeyLink" href="https://torbox.app/settings" target="_blank">Get It Here</a>
|
||||
<a id="support"></a>
|
||||
<a id="warning" href="https://rentry.co/easydebrid" target="_blank"></a>
|
||||
</label>
|
||||
<sl-input id="debridApiKey" placeholder="Enter API key" help-text="If no key is specified, you'll get direct torrents!"></sl-input>
|
||||
</div>
|
||||
@@ -573,33 +570,17 @@
|
||||
document.getElementById("debridService").addEventListener("sl-change", function(event) {
|
||||
const selectedService = event.target.value;
|
||||
const apiKeyLink = document.getElementById("apiKeyLink");
|
||||
support = document.getElementById("support");
|
||||
warning = document.getElementById("warning");
|
||||
|
||||
if (selectedService === "realdebrid") {
|
||||
apiKeyLink.href = "https://real-debrid.com/apitoken";
|
||||
support.textContent = "";
|
||||
warning.textContent = "";
|
||||
} else if (selectedService === "alldebrid") {
|
||||
apiKeyLink.href = "https://alldebrid.com/apikeys";
|
||||
support.textContent = "";
|
||||
warning.textContent = "";
|
||||
} else if (selectedService === "premiumize") {
|
||||
apiKeyLink.href = "https://premiumize.me/account";
|
||||
support.textContent = "";
|
||||
warning.textContent = "";
|
||||
} else if (selectedService === "torbox") {
|
||||
apiKeyLink.href = "https://torbox.app/settings";
|
||||
support.textContent = "";
|
||||
warning.textContent = "";
|
||||
} else if (selectedService === "debridlink") {
|
||||
apiKeyLink.href = "https://debrid-link.com/webapp/apikey";
|
||||
support.textContent = "";
|
||||
warning.textContent = "";
|
||||
} else if (selectedService === "easydebrid") {
|
||||
apiKeyLink.href = "https://paradise-cloud.com/products/easydebrid";
|
||||
support.textContent = " - Support me by using promo code 'goldy'! (5% OFF) - ";
|
||||
warning.textContent = "warning";
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -269,7 +269,6 @@ def get_debrid_extension(debridService: str, debridApiKey: str = None):
|
||||
"premiumize": "PM",
|
||||
"torbox": "TB",
|
||||
"debridlink": "DL",
|
||||
"easydebrid": "ED",
|
||||
}
|
||||
|
||||
return debrid_extensions.get(debridService, None)
|
||||
|
||||
@@ -123,7 +123,7 @@ class ConfigModel(BaseModel):
|
||||
|
||||
@field_validator("debridService")
|
||||
def check_debrid_service(cls, v):
|
||||
if v not in ["realdebrid", "alldebrid", "premiumize", "torbox", "debridlink", "easydebrid"]:
|
||||
if v not in ["realdebrid", "alldebrid", "premiumize", "torbox", "debridlink"]:
|
||||
raise ValueError("Invalid debridService")
|
||||
return v
|
||||
|
||||
|
||||
Reference in New Issue
Block a user