diff --git a/main.py b/main.py index 5d2f5a2..c3cbd1d 100644 --- a/main.py +++ b/main.py @@ -154,12 +154,22 @@ def logout(): def index(): """Render the dashboard with all videos sorted by date.""" try: + channel_id = request.args.get("channel") + with get_db_session() as session: - # Query videos for current user's channels, sorted by published date (newest first) - videos = session.query(VideoEntry).join(Channel).filter( - Channel.user_id == current_user.id, - VideoEntry.download_status == DownloadStatus.COMPLETED - ).order_by(desc(VideoEntry.published_at)).all() + # Base query for current user's videos + query = session.query(VideoEntry).join(Channel).filter( + Channel.user_id == current_user.id + ) + + # If channel filter is specified, show ALL videos from that channel + if channel_id: + query = query.filter(Channel.id == int(channel_id)) + else: + # Otherwise, only show completed videos + query = query.filter(VideoEntry.download_status == DownloadStatus.COMPLETED) + + videos = query.order_by(desc(VideoEntry.published_at)).all() return render_template("dashboard.html", videos=videos) except Exception as e: