Added Progress bar to Active Streams
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
# 1.0.6
|
||||||
|
|
||||||
|
- Added Progress bar to Active Streams
|
||||||
|
|
||||||
# 1.0.5
|
# 1.0.5
|
||||||
|
|
||||||
- Added Timezone support in .env
|
- Added Timezone support in .env
|
||||||
|
|||||||
15
app.py
15
app.py
@@ -830,7 +830,7 @@ async def scanlibraries(ctx):
|
|||||||
|
|
||||||
@bot.command()
|
@bot.command()
|
||||||
async def activestreams(ctx):
|
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):
|
if not has_admin_role(ctx.author):
|
||||||
await ctx.send("❌ You don’t have permission to use this command.")
|
await ctx.send("❌ You don’t have permission to use this command.")
|
||||||
return
|
return
|
||||||
@@ -869,13 +869,20 @@ async def activestreams(ctx):
|
|||||||
# Get progress
|
# Get progress
|
||||||
try:
|
try:
|
||||||
position_ticks = session.get("PlayState", {}).get("PositionTicks", 0)
|
position_ticks = session.get("PlayState", {}).get("PositionTicks", 0)
|
||||||
runtime_ticks = media.get("RunTimeTicks", 1) # fallback to avoid division by zero
|
runtime_ticks = media.get("RunTimeTicks", 1) # avoid div by zero
|
||||||
# Convert ticks to seconds (1 tick = 100 ns)
|
|
||||||
position_seconds = position_ticks / 10_000_000
|
position_seconds = position_ticks / 10_000_000
|
||||||
runtime_seconds = runtime_ticks / 10_000_000
|
runtime_seconds = runtime_ticks / 10_000_000
|
||||||
|
|
||||||
position_str = str(datetime.timedelta(seconds=int(position_seconds)))
|
position_str = str(datetime.timedelta(seconds=int(position_seconds)))
|
||||||
runtime_str = str(datetime.timedelta(seconds=int(runtime_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:
|
except Exception:
|
||||||
progress_str = "Unknown"
|
progress_str = "Unknown"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user