Add podgrab featureset
This commit is contained in:
parent
095bf52a2f
commit
233dd5b5c0
33 changed files with 2315 additions and 125 deletions
|
@ -33,6 +33,37 @@ def dashboard():
|
|||
# Get statistics
|
||||
total_podcasts = Podcast.query.count()
|
||||
|
||||
# Get episode statistics
|
||||
from app.models.podcast import Episode
|
||||
total_episodes = Episode.query.count()
|
||||
downloaded_episodes = Episode.query.filter_by(downloaded=True).count()
|
||||
not_downloaded_episodes = total_episodes - downloaded_episodes
|
||||
|
||||
# Calculate total storage used (in bytes)
|
||||
from sqlalchemy import func
|
||||
total_storage_bytes = Episode.query.filter_by(downloaded=True).with_entities(
|
||||
func.sum(Episode.file_size)).scalar() or 0
|
||||
|
||||
# Format storage size in appropriate units
|
||||
def format_size(size_bytes):
|
||||
# Convert bytes to appropriate unit
|
||||
if size_bytes < 1024:
|
||||
return f"{size_bytes} B"
|
||||
elif size_bytes < 1024 * 1024:
|
||||
return f"{size_bytes / 1024:.2f} KB"
|
||||
elif size_bytes < 1024 * 1024 * 1024:
|
||||
return f"{size_bytes / (1024 * 1024):.2f} MB"
|
||||
elif size_bytes < 1024 * 1024 * 1024 * 1024:
|
||||
return f"{size_bytes / (1024 * 1024 * 1024):.2f} GB"
|
||||
else:
|
||||
return f"{size_bytes / (1024 * 1024 * 1024 * 1024):.2f} TB"
|
||||
|
||||
formatted_storage = format_size(total_storage_bytes)
|
||||
|
||||
return render_template('dashboard.html',
|
||||
title='Dashboard',
|
||||
total_podcasts=total_podcasts)
|
||||
total_podcasts=total_podcasts,
|
||||
total_episodes=total_episodes,
|
||||
downloaded_episodes=downloaded_episodes,
|
||||
not_downloaded_episodes=not_downloaded_episodes,
|
||||
formatted_storage=formatted_storage)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue