diff --git a/CHANGELOG.md b/CHANGELOG.md index b5a8d56..cc4ee9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 1.0.6 + +- Added Progress bar to Active Streams + # 1.0.5 - Added Timezone support in .env diff --git a/app.py b/app.py index 528c17c..00b59b5 100644 --- a/app.py +++ b/app.py @@ -830,7 +830,7 @@ async def scanlibraries(ctx): @bot.command() async def activestreams(ctx): - """Admin-only: Show currently active Jellyfin user streams (movies/episodes only) with progress.""" + """Admin-only: Show currently active Jellyfin user streams (movies/episodes only) with progress bar.""" if not has_admin_role(ctx.author): await ctx.send("❌ You don’t have permission to use this command.") return @@ -869,13 +869,20 @@ async def activestreams(ctx): # Get progress try: position_ticks = session.get("PlayState", {}).get("PositionTicks", 0) - runtime_ticks = media.get("RunTimeTicks", 1) # fallback to avoid division by zero - # Convert ticks to seconds (1 tick = 100 ns) + runtime_ticks = media.get("RunTimeTicks", 1) # avoid div by zero position_seconds = position_ticks / 10_000_000 runtime_seconds = runtime_ticks / 10_000_000 + position_str = str(datetime.timedelta(seconds=int(position_seconds))) runtime_str = str(datetime.timedelta(seconds=int(runtime_seconds))) - progress_str = f"[{position_str} / {runtime_str}]" + + # Progress bar + percent = position_seconds / runtime_seconds if runtime_seconds > 0 else 0 + bar_length = 10 + filled_length = int(round(bar_length * percent)) + bar = "■" * filled_length + "□" * (bar_length - filled_length) + + progress_str = f"{bar} {int(percent*100)}%\n[{position_str} / {runtime_str}]" except Exception: progress_str = "Unknown"