- Refactor of StreamsContext:

Added `featuredCategories` section,
Added personalised variations of HomePage contents;
- Removal of redundant/unused files from backend;
- Update to README: Updated to current method for deploying;
- Known bug: StreamsContext is being called before AuthContext, leading to unpersonalised streams & categories each time, even when logged in;
This commit is contained in:
Chris-1010
2025-01-24 17:23:56 +00:00
parent b9e912af1d
commit 5c16092b1c
18 changed files with 200 additions and 121 deletions

View File

@@ -1,2 +0,0 @@
FLASK_APP=backend.blueprints.__init__
FLASK_DEBUG=True

View File

@@ -1,6 +1,5 @@
from flask import Blueprint, session, request, url_for, redirect, g, jsonify
from flask import Blueprint, session, request, jsonify
from werkzeug.security import generate_password_hash, check_password_hash
from forms import SignupForm, LoginForm
from flask_cors import cross_origin
from database.database import Database
from blueprints.utils import login_required

View File

@@ -12,8 +12,4 @@ def hls(stream_id):
# --------------------------------------------------------
# TODO Route for saving uploaded thumbnails to database, serving these images to the frontend upon request: →→→ @main_bp.route('/images/<path:filename>') \n def serve_image(filename): ←←←

View File

@@ -2,63 +2,152 @@ from flask import Blueprint
stream_bp = Blueprint("stream", __name__)
@stream_bp.route('/get_streams', methods=['GET'])
def get_sample_streams():
"""
Returns a list of (sample) streamers live right now
Returns a list of (sample) streams live right now
"""
# top 25, if not logged in
# if logged in, show streams that match user's tags
# user attains tags from the tags of the streamers they follow, and streamers they've watched
# user attains tags from the tags of the streamers they follow, and streamers they've watched
streamers = [
{
"id": 1,
"title": "Gaming Stream",
"streamer": "Gamer123",
"viewers": 1500,
"thumbnail": "dance_game.png",
},
{
"id": 2,
"title": "Art Stream",
"streamer": "Artist456",
"viewers": 800,
"thumbnail": "surface.jpeg",
},
{
"id": 3,
"title": "Music Stream",
"streamer": "Musician789",
"viewers": 2000,
"thumbnail": "monkey.png",
},
{
"id": 4,
"title": "Just Chatting",
"streamer": "Chatty101",
"viewers": 1200,
"thumbnail": "elf.webp",
},
{
"id": 5,
"title": "Cooking Stream",
"streamer": "Chef202",
"viewers": 1000,
"thumbnail": "art.jpg",
}
]
return streamers
# TODO Add a category field to the stream object
streams = [
{
"id": 1,
"title": "Gaming Stream",
"streamer": "Gamer123",
"viewers": 1500,
"thumbnail": "dance_game.png",
},
{
"id": 2,
"title": "Art Stream",
"streamer": "Artist456",
"viewers": 800,
"thumbnail": "surface.jpeg",
},
{
"id": 3,
"title": "Music Stream",
"streamer": "Musician789",
"viewers": 2000,
"thumbnail": "monkey.png",
},
{
"id": 4,
"title": "Just Chatting",
"streamer": "Chatty101",
"viewers": 1200,
"thumbnail": "chatting_category.jpg",
},
{
"id": 5,
"title": "Cooking Stream",
"streamer": "Chef202",
"viewers": 1000,
"thumbnail": "cooking_category.jpg",
}
]
return streams
@stream_bp.route('/get_recommended_streams', methods=['GET'])
def get_recommended_streamers():
def get_recommended_streams():
"""
Queries DB to get a list of recommended streamers using an algorithm
Queries DB to get a list of recommended streams using an algorithm
"""
return [
{
"id": 1,
"title": "Fake Game Showcase w/ Devs",
"streamer": "Gamer_boy9000",
"viewers": 15458,
"thumbnail": "game1.jpg",
}, {
"id": 2,
"title": "Game OSTs I like!",
"streamer": "GéMusicLover",
"viewers": 52911,
"thumbnail": "game_music1.jpg",
},
{
"id": 3,
"title": "Chill Stream - Cooking with Chef Ramsay",
"streamer": "HarrietDgoat",
"viewers": 120283,
# Intentionally left out thumbnail to showcase placeholder image
}]
@stream_bp.route('/get_categories', methods=['GET'])
def get_categories():
"""
Returns a list of (sample) categories being watched right now
"""
return [
{
"id": 1,
"title": "Gaming",
"viewers": 220058,
"thumbnail": "gaming_category.jpg",
},
{
"id": 2,
"title": "Music",
"viewers": 150060,
"thumbnail": "music_category.webp",
},
{
"id": 3,
"title": "Art",
"viewers": 10200,
"thumbnail": "art_category.jpg",
},
{
"id": 4,
"title": "Cooking",
"viewers": 8000,
"thumbnail": "cooking_category.jpg",
},
{
"id": 5,
"title": "Just Chatting",
"viewers": 83900,
"thumbnail": "chatting_category.jpg",
}
]
@stream_bp.route('/get_followed_categories', methods=['GET'])
def get_followed_categories():
"""
Queries DB to get a list of followed categories
"""
categories = []
if categories:
return categories
return get_categories()
@stream_bp.route('/get_streamer_data/<int:streamer_id>', methods=['GET'])
def get_streamer(streamer_id):
"""
Returns a streamer's data
"""
return
@stream_bp.route('/get_stream_data/<int:streamer_id>', methods=['GET'])
def get_stream(streamer_id):
"""
Returns a streamer's stream data
"""
return
@stream_bp.route('/get_followed_streams', methods=['GET'])
def get_followed_streamers():
"""
@@ -66,9 +155,10 @@ def get_followed_streamers():
"""
return
@stream_bp.route('/save_stream_thumbnail/<int:streamer_id>', methods=['POST'])
def stream_thumbnail_snapshot(streamer_id):
"""
Function to be called periodically which saves the current live stream as an img to be used for the thumbnail to be displayed
"""
return
return

View File

@@ -1,31 +0,0 @@
{
"name": "web_server",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"dependencies": {
"lucide-react": "^0.473.0"
}
},
"node_modules/lucide-react": {
"version": "0.473.0",
"resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.473.0.tgz",
"integrity": "sha512-KW6u5AKeIjkvrxXZ6WuCu9zHE/gEYSXCay+Gre2ZoInD0Je/e3RBtP4OHpJVJ40nDklSvjVKjgH7VU8/e2dzRw==",
"license": "ISC",
"peerDependencies": {
"react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0"
}
},
"node_modules/react": {
"version": "19.0.0",
"resolved": "https://registry.npmjs.org/react/-/react-19.0.0.tgz",
"integrity": "sha512-V8AVnmPIICiWpGfm6GLzCR/W5FXLchHop40W4nXBmdlEceh16rCN8O8LNWm5bh5XUX91fh7KpA+W0TgMKmgTpQ==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=0.10.0"
}
}
}
}

View File

@@ -1,5 +0,0 @@
{
"dependencies": {
"lucide-react": "^0.473.0"
}
}