Spaces:
Sleeping
Sleeping
from fastapi import APIRouter | |
import trending_videos_page | |
from sqlalchemy.orm import Session | |
router=APIRouter() | |
def trending_videos_count(): | |
data = trending_videos_page.get_trending_videos_count() | |
return {"trending_video_counts": data.to_dict()} | |
def most_popular_categories(): | |
data = trending_videos_page.get_most_popular_categories() | |
return {"most_popular_categories": data.to_dict()} | |
def like_ratio_distribution(): | |
data = trending_videos_page.get_like_ratio_distribution() | |
return {"like_ratio_distribution": data.to_dict(orient="records")} | |
def top_liked_videos(): | |
data = trending_videos_page.get_top_liked_videos() | |
return {"top_liked_videos": data.to_dict(orient="records")} | |
def top_trending_channels(): | |
data = trending_videos_page.get_trending_channels() | |
channel_counts = data["channelTitle"].value_counts().to_dict() | |
return {"top_trending_channels": channel_counts} | |
def channel_growth_over_time(): | |
growth_data =trending_videos_page.calculate_channel_growth() | |
return growth_data.to_dict(orient="records") | |
def get_tags_analysis(): | |
popular_tags = trending_videos_page.process_tags() | |
return popular_tags | |
def get_trending_by_day(): | |
analyze_trending_daily=trending_videos_page.analyze_upload_patterns("day") | |
return analyze_trending_daily | |
def get_category_like_view_ratio(): | |
data = trending_videos_page.category_like_view_ratio() | |
return {"data": data} | |
def get_category_comment_engagement(): | |
data = trending_videos_page.category_comment_engagement() | |
return {"data": data} |