Add live download progress updates
This commit is contained in:
@@ -382,14 +382,14 @@ def _artwork_url(path: Optional[str], size: str, cache_mode: str) -> Optional[st
|
||||
return f"https://image.tmdb.org/t/p/{size}{path}"
|
||||
|
||||
|
||||
def _torrent_progress(torrent: Dict[str, Any]) -> Optional[int]:
|
||||
def _torrent_progress(torrent: Dict[str, Any]) -> Optional[float]:
|
||||
progress = torrent.get("progress")
|
||||
try:
|
||||
numeric = float(progress)
|
||||
except (TypeError, ValueError):
|
||||
numeric = -1
|
||||
if 0 <= numeric <= 1:
|
||||
return round(numeric * 100)
|
||||
return round(numeric * 100, 1)
|
||||
try:
|
||||
size = float(torrent.get("size"))
|
||||
amount_left = float(torrent.get("amount_left"))
|
||||
@@ -397,7 +397,7 @@ def _torrent_progress(torrent: Dict[str, Any]) -> Optional[int]:
|
||||
return None
|
||||
if size <= 0:
|
||||
return None
|
||||
return max(0, min(100, round(((size - amount_left) / size) * 100)))
|
||||
return max(0.0, min(100.0, round(((size - amount_left) / size) * 100, 1)))
|
||||
|
||||
|
||||
def _build_presentation(
|
||||
|
||||
Reference in New Issue
Block a user