Add channel filtering to videos view
- 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 <noreply@anthropic.com>
This commit is contained in:
20
main.py
20
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:
|
||||
|
||||
Reference in New Issue
Block a user