File size: 1,986 Bytes
74bdacd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from fastapi import APIRouter
import trending_videos_page
from sqlalchemy.orm import Session
router=APIRouter()

@router.get("/trending_videos_count")
def trending_videos_count():
    data = trending_videos_page.get_trending_videos_count()
    return {"trending_video_counts": data.to_dict()}


@router.get("/most_popular_categories")
def most_popular_categories():
    data = trending_videos_page.get_most_popular_categories()
    return {"most_popular_categories": data.to_dict()}

@router.get("/engagement/like_ratio_distribution")
def like_ratio_distribution():
    data = trending_videos_page.get_like_ratio_distribution()
    return {"like_ratio_distribution": data.to_dict(orient="records")}


@router.get("/engagement/top_liked_videos")
def top_liked_videos():
    data = trending_videos_page.get_top_liked_videos()
    return {"top_liked_videos": data.to_dict(orient="records")}


@router.get("/channel-performance/top-trending")
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}


@router.get("/channel-performance/growth-over-time")
def channel_growth_over_time():
    growth_data =trending_videos_page.calculate_channel_growth()
    return growth_data.to_dict(orient="records")

@router.get("/analysis")
def get_tags_analysis():
    popular_tags = trending_videos_page.process_tags()
    return popular_tags


@router.get("/duration_vs_likes")
def get_trending_by_day():
    analyze_trending_daily=trending_videos_page.analyze_upload_patterns("day")
    return analyze_trending_daily


@router.get("/category-like-view-ratio")
def get_category_like_view_ratio():
    data = trending_videos_page.category_like_view_ratio()
    return {"data": data}

@router.get("/category-comment-engagement")
def get_category_comment_engagement():
    data = trending_videos_page.category_comment_engagement()
    return {"data": data}