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():
|
def index():
|
||||||
"""Render the dashboard with all videos sorted by date."""
|
"""Render the dashboard with all videos sorted by date."""
|
||||||
try:
|
try:
|
||||||
|
channel_id = request.args.get("channel")
|
||||||
|
|
||||||
with get_db_session() as session:
|
with get_db_session() as session:
|
||||||
# Query videos for current user's channels, sorted by published date (newest first)
|
# Base query for current user's videos
|
||||||
videos = session.query(VideoEntry).join(Channel).filter(
|
query = session.query(VideoEntry).join(Channel).filter(
|
||||||
Channel.user_id == current_user.id,
|
Channel.user_id == current_user.id
|
||||||
VideoEntry.download_status == DownloadStatus.COMPLETED
|
)
|
||||||
).order_by(desc(VideoEntry.published_at)).all()
|
|
||||||
|
# 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)
|
return render_template("dashboard.html", videos=videos)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user