Skip to content

Commit

Permalink
ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
g0ldyy committed Jul 8, 2024
1 parent 6b8303b commit a563478
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
21 changes: 16 additions & 5 deletions comet/api/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,23 @@ async def stream(request: Request, b64config: str, type: str, id: str):
balanced_hashes = await get_balanced_hashes(sorted_ranked_files, config)

results = []
if (settings.PROXY_DEBRID_STREAM and settings.PROXY_DEBRID_STREAM_PASSWORD != config["debridStreamProxyPassword"]):
if (
settings.PROXY_DEBRID_STREAM
and settings.PROXY_DEBRID_STREAM_PASSWORD
!= config["debridStreamProxyPassword"]
):
results.append(
{
"name": "[⚠️] Comet",
"title": f"Debrid Stream Proxy Password incorrect.\nStreams will not be proxied.",
"title": "Debrid Stream Proxy Password incorrect.\nStreams will not be proxied.",
"url": "https://comet.fast",
}
)

for hash, hash_data in sorted_ranked_files.items(): # Like that to keep ranking order
for (
hash,
hash_data,
) in sorted_ranked_files.items(): # Like that to keep ranking order
for resolution, hash_list in balanced_hashes.items():
if hash in hash_list:
results.append(
Expand Down Expand Up @@ -309,11 +316,15 @@ async def stream(request: Request, b64config: str, type: str, id: str):
balanced_hashes = await get_balanced_hashes(sorted_ranked_files, config)

results = []
if (settings.PROXY_DEBRID_STREAM and settings.PROXY_DEBRID_STREAM_PASSWORD != config["debridStreamProxyPassword"]):
if (
settings.PROXY_DEBRID_STREAM
and settings.PROXY_DEBRID_STREAM_PASSWORD
!= config["debridStreamProxyPassword"]
):
results.append(
{
"name": "[⚠️] Comet",
"title": f"Debrid Stream Proxy Password incorrect.\nStreams will not be proxied.",
"title": "Debrid Stream Proxy Password incorrect.\nStreams will not be proxied.",
"url": "https://comet.fast",
}
)
Expand Down
2 changes: 1 addition & 1 deletion comet/debrid/alldebrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def get_files(
for file in magnet["files"]:
filename = file["n"]
pack = False
if "e" in file: # PACK
if "e" in file: # PACK
filename = file["e"][0]["n"]
pack = True

Expand Down
13 changes: 9 additions & 4 deletions comet/utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ def bytes_to_size(bytes: int):
sizes = ["Bytes", "KB", "MB", "GB", "TB"]
if bytes == 0:
return "0 Byte"

i = 0
while bytes >= 1024 and i < len(sizes) - 1:
bytes /= 1024
i += 1

return f"{round(bytes, 2)} {sizes[i]}"


Expand Down Expand Up @@ -247,10 +247,15 @@ async def get_indexer_manager(

async def filter(torrents: list, name_lower: str, indexer_manager_type: str):
valid_torrents = [
torrent for torrent in torrents
torrent
for torrent in torrents
if title_match(
name_lower,
parse(torrent["Title"] if indexer_manager_type == "jackett" else torrent["title"]).parsed_title.lower()
parse(
torrent["Title"]
if indexer_manager_type == "jackett"
else torrent["title"]
).parsed_title.lower(),
)
]

Expand Down
5 changes: 4 additions & 1 deletion comet/utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ class ConfigModel(BaseModel):

@field_validator("indexers")
def check_indexers(cls, v, values):
settings.INDEXER_MANAGER_INDEXERS = [indexer.replace(" ", "_").lower() for indexer in settings.INDEXER_MANAGER_INDEXERS] # to equal webui
settings.INDEXER_MANAGER_INDEXERS = [
indexer.replace(" ", "_").lower()
for indexer in settings.INDEXER_MANAGER_INDEXERS
] # to equal webui
valid_indexers = [
indexer for indexer in v if indexer in settings.INDEXER_MANAGER_INDEXERS
]
Expand Down

0 comments on commit a563478

Please sign in to comment.