This commit is contained in:
2025-03-01 08:28:19 +00:00
6 changed files with 70 additions and 6 deletions

View File

@@ -97,7 +97,7 @@ const CategoryPage: React.FC = () => {
<ListRow <ListRow
ref={listRowRef} ref={listRowRef}
type="stream" type="stream"
title={`${categoryName} Streams`} title={`${categoryName}`}
description={`Live streams in the ${categoryName} category`} description={`Live streams in the ${categoryName} category`}
items={streams} items={streams}
wrap={true} wrap={true}

View File

@@ -1,12 +1,11 @@
import React from "react"; import React from "react";
import ListRow from "../components/Layout/ListRow"; import ListRow from "../components/Layout/ListRow";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { useStreams, useCategories } from "../hooks/useContent"; import { useStreams, useCategories, useVods } from "../hooks/useContent";
import Button from "../components/Input/Button"; import Button from "../components/Input/Button";
import DynamicPageContent from "../components/Layout/DynamicPageContent"; import DynamicPageContent from "../components/Layout/DynamicPageContent";
import LoadingScreen from "../components/Layout/LoadingScreen"; import LoadingScreen from "../components/Layout/LoadingScreen";
import Footer from "../components/Layout/Footer"; import Footer from "../components/Layout/Footer";
import { useVods } from "../hooks/useContent"; // Import useVods
interface HomePageProps { interface HomePageProps {

View File

@@ -162,6 +162,17 @@ def vods(username):
vods = get_user_vods(user_id) vods = get_user_vods(user_id)
return jsonify(vods) return jsonify(vods)
@stream_bp.route('/vods/all')
def get_all_vods():
"""
Returns data of all VODs by all streamers in a JSON-compatible format
"""
with Database() as db:
vods = db.fetchall("SELECT * FROM vods")
print("Fetched VODs from DB:", vods)
return jsonify(vods)
# RTMP Server Routes # RTMP Server Routes
@@ -187,7 +198,7 @@ def init_stream():
# Create necessary directories # Create necessary directories
username = user_info["username"] username = user_info["username"]
create_user_directories(username) create_local_directories(username)
return redirect(f"/stream/{username}") return redirect(f"/stream/{username}")
@@ -205,6 +216,7 @@ def publish_stream():
periodically update thumbnail periodically update thumbnail
""" """
try: try:
data = json.loads(request.form.get("data")) data = json.loads(request.form.get("data"))
except json.JSONDecodeError as ex: except json.JSONDecodeError as ex:

Binary file not shown.

View File

@@ -4,7 +4,29 @@ INSERT INTO users (username, password, email, num_followers, stream_key, is_part
('MusicLover', 'music4life', 'musiclover@example.com', 1200, '2345', 0, 'I share my favorite tunes.', 1, 0), ('MusicLover', 'music4life', 'musiclover@example.com', 1200, '2345', 0, 'I share my favorite tunes.', 1, 0),
('ArtFan', 'artistic123', 'artfan@example.com', 300, '3456', 0, 'Exploring the world of art.', 1, 0), ('ArtFan', 'artistic123', 'artfan@example.com', 300, '3456', 0, 'Exploring the world of art.', 1, 0),
('EduGuru', 'learn123', 'eduguru@example.com', 800, '4567', 0, 'Teaching everything I know.', 1, 0), ('EduGuru', 'learn123', 'eduguru@example.com', 800, '4567', 0, 'Teaching everything I know.', 1, 0),
('SportsStar', 'sports123', 'sportsstar@example.com', 2000, '5678', 0, 'Join me for live sports updates!', 1, 0); ('SportsStar', 'sports123', 'sportsstar@example.com', 2000, '5678', 0, 'Join me for live sports updates!', 1, 0),
('TechEnthusiast', NULL, 'techenthusiast@example.com', 1500, '6789', 0, 'All about the latest tech news!', 1, 0),
('ChefMaster', NULL, 'chefmaster@example.com', 700, '7890', 0, 'Cooking live and sharing recipes.', 1, 0),
('TravelExplorer', NULL, 'travelexplorer@example.com', 900, '8901', 0, 'Exploring new places every day!', 1, 0),
('BookLover', NULL, 'booklover@example.com', 450, '9012', 0, 'Sharing my thoughts on every book I read.', 1, 0),
('FitnessFan', NULL, 'fitnessfan@example.com', 1300, '0123', 0, 'Join my fitness journey!', 1, 0),
('NatureLover', NULL, 'naturelover@example.com', 1100, '2346', 0, 'Live streaming nature walks and hikes.', 1, 0),
('MovieBuff', NULL, 'moviebuff@example.com', 800, '3457', 0, 'Sharing movie reviews and recommendations.', 1, 0),
('ScienceGeek', NULL, 'sciencegeek@example.com', 950, '4568', 0, 'Exploring the wonders of science.', 1, 0),
('Comedian', NULL, 'comedian@example.com', 650, '5679', 0, 'Bringing laughter with live stand-up comedy.', 1, 0),
('Fashionista', NULL, 'fashionista@example.com', 1200, '6780', 0, 'Join me for live fashion tips and trends.', 1, 0),
('HealthGuru', NULL, 'healthguru@example.com', 1400, '7891', 0, 'Live streaming health and wellness advice.', 1, 0),
('CarLover', NULL, 'carlove@example.com', 1700, '8902', 0, 'Streaming car reviews and automotive content.', 1, 0),
('PetLover', NULL, 'petlover@example.com', 1000, '9013', 0, 'Join me for fun and cute pet moments!', 1, 0),
('Dancer', NULL, 'dancer@example.com', 2000, '0124', 0, 'Sharing live dance performances.', 1, 0),
('Photographer', NULL, 'photographer@example.com', 1300, '1235', 0, 'Live streaming photography tutorials.', 1, 0),
('Motivator', NULL, 'motivator@example.com', 850, '2347', 0, 'Join me for daily motivation and positivity.', 1, 0),
('LanguageLearner', NULL, 'languagelearner@example.com', 950, '3458', 0, 'Live streaming language learning sessions.', 1, 0),
('HistoryBuff', NULL, 'historybuff@example.com', 750, '4569', 0, 'Exploring history live and in depth.', 1, 0),
('Blogger', NULL, 'blogger@example.com', 1200, '5670', 0, 'Sharing my experiences through live blogging.', 1, 0),
('DIYer', NULL, 'diyer@example.com', 1300, '6781', 0, 'Live streaming DIY projects and tutorials.', 1, 0),
('SportsAnalyst', NULL, 'sportsanalyst@example.com', 1400, '7892', 0, 'Live commentary and analysis on sports events.', 1, 0),
('LBozo', NULL, 'lbozo@example.com', 0, '250', 0, 'I like taking Ls.', 1, 0);
INSERT INTO users (username, password, email, num_followers, stream_key, is_partnered, bio, is_live, is_admin) VALUES INSERT INTO users (username, password, email, num_followers, stream_key, is_partnered, bio, is_live, is_admin) VALUES
('GamerDude2', 'password123', 'gamerdude3@gmail.com', 3200, '7890', 0, 'Streaming my gaming adventures!', 0, 0), ('GamerDude2', 'password123', 'gamerdude3@gmail.com', 3200, '7890', 0, 'Streaming my gaming adventures!', 0, 0),
@@ -36,6 +58,7 @@ INSERT INTO subscribes (user_id, subscribed_id, since, expires) VALUES
(4, 5, '2024-09-12', '2025-01-12'), (4, 5, '2024-09-12', '2025-01-12'),
(5, 1, '2024-08-30', '2025-02-28'); (5, 1, '2024-08-30', '2025-02-28');
-- Sample Data for followed_categories -- Sample Data for followed_categories
INSERT INTO followed_categories (user_id, category_id) VALUES INSERT INTO followed_categories (user_id, category_id) VALUES
(1, 1), (1, 1),
@@ -83,7 +106,29 @@ INSERT INTO streams (user_id, title, start_time, category_id) VALUES
(2, 'Live Music Jam', '2025-01-25 20:00:00', 2), (2, 'Live Music Jam', '2025-01-25 20:00:00', 2),
(3, 'Sketching Live', '2025-01-24 15:00:00', 3), (3, 'Sketching Live', '2025-01-24 15:00:00', 3),
(4, 'Math Made Easy', '2025-01-23 10:00:00', 4), (4, 'Math Made Easy', '2025-01-23 10:00:00', 4),
(5, 'Sports Highlights', '2025-02-15 23:00:00', 5); (5, 'Sports Highlights', '2025-02-15 23:00:00', 5),
(6, 'Genshin1', '2025-02-17 18:00:00', 22),
(7, 'Genshin2', '2025-02-18 19:00:00', 22),
(8, 'Genshin3', '2025-02-19 20:00:00', 22),
(9, 'Genshin4', '2025-02-20 14:00:00', 22),
(10, 'Genshin5', '2025-02-21 09:00:00', 22),
(11, 'Genshin6', '2025-02-22 11:00:00', 22),
(12, 'Genshin7', '2025-02-23 21:00:00', 22),
(13, 'Genshin8', '2025-02-24 16:00:00', 22),
(14, 'Genshin9', '2025-02-25 22:00:00', 22),
(15, 'Genshin10', '2025-02-26 18:30:00', 22),
(16, 'Genshin11', '2025-02-27 17:00:00', 22),
(17, 'Genshin12', '2025-02-28 15:00:00', 22),
(18, 'Genshin13', '2025-03-01 10:00:00', 22),
(19, 'Genshin14', '2025-03-02 20:00:00', 22),
(20, 'Genshin15', '2025-03-03 13:00:00', 22),
(21, 'Genshin16', '2025-03-04 09:00:00', 22),
(22, 'Genshin17', '2025-03-05 12:00:00', 22),
(23, 'Genshin18', '2025-03-06 14:00:00', 22),
(24, 'Genshin19', '2025-03-07 16:00:00', 22),
(25, 'Genshin20', '2025-03-08 19:00:00', 22),
(26, 'Genshin21', '2025-03-09 21:00:00', 22),
(27, 'Genshin22', '2025-03-10 17:00:00', 11);
-- Sample Data for vods -- Sample Data for vods
INSERT INTO vods (user_id, title, datetime, category_id, length, views) VALUES INSERT INTO vods (user_id, title, datetime, category_id, length, views) VALUES

View File

@@ -84,6 +84,14 @@ def get_user_vods(user_id: int):
vods = db.fetchall("""SELECT * FROM vods WHERE user_id = ?;""", (user_id,)) vods = db.fetchall("""SELECT * FROM vods WHERE user_id = ?;""", (user_id,))
return vods return vods
def get_all_vods():
"""
Returns data of all VODs by all streamers in a JSON-compatible format
"""
with Database() as db:
vods = db.fetchall("""SELECT * FROM vods""")
return vods
def generate_thumbnail(stream_file: str, thumbnail_file: str, retry_time=5, retry_count=3) -> None: def generate_thumbnail(stream_file: str, thumbnail_file: str, retry_time=5, retry_count=3) -> None:
""" """
Generates the thumbnail of a stream Generates the thumbnail of a stream