Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/clients/stremio/addon_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,14 @@ def parse_torrent_description(self, desc: str) -> Dict[str, Any]:
"languages": [],
}
# Extract size
size_pattern = r"💾 ([\d.]+ (?:GB|MB))"
size_match = re.search(size_pattern, desc)
size_pattern = r"💾 ([\d.,]+ (?:GB|MB|Go|Mo))"
size_match = re.search(size_pattern, desc, re.IGNORECASE)
size = size_match.group(1) if size_match else None
if size:
size = convert_size_to_bytes(size)

# Extract seeders
seeders_pattern = r"👤 (\d+)"
seeders_pattern = r"[👥👤] (\d+)"
seeders_match = re.search(seeders_pattern, desc)
seeders = int(seeders_match.group(1)) if seeders_match else None

Expand Down
9 changes: 5 additions & 4 deletions lib/utils/kodi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,17 +519,18 @@ def bytes_to_human_readable(size: int, unit: str = "B") -> str:

def convert_size_to_bytes(size_str: str) -> int:
"""Convert size string to bytes."""
match = re.match(r"(\d+(?:\.\d+)?)\s*(GB|MB|KB|B)", size_str, re.IGNORECASE)
size_str = size_str.replace(",", ".")
match = re.match(r"(\d+(?:\.\d+)?)\s*(GB|MB|KB|B|Go|Mo|Ko)", size_str, re.IGNORECASE)

if match:
size, unit = match.groups()
size = float(size)
unit = unit.upper()
if unit == "GB":
if unit in ("GB", "GO"):
return int(size * 1024**3)
if unit == "MB":
if unit in ("MB", "MO"):
return int(size * 1024**2)
if unit == "KB":
if unit in ("KB", "KO"):
return int(size * 1024)
return int(size)
return 0
Expand Down