From f2ec1335a90b6609c2eab84ca36e7764a4c07ea0 Mon Sep 17 00:00:00 2001 From: Ryan Chen Date: Wed, 26 Nov 2025 21:01:16 -0500 Subject: [PATCH] Add channel filtering to videos view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update index route to accept optional channel query parameter - Show ALL videos (any status) when filtering by specific channel - Show only completed videos on main dashboard (no filter) - Allows viewing all videos in a feed via "View Videos" button 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- main.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) 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: