import gradio as gr import requests import os import pickle headers = { "X-RapidAPI-Key": os.getenv('TIKTOK_API'), "X-RapidAPI-Host": "tiktok-scraper7.p.rapidapi.com" } with open('model_scaler.pkl', 'rb') as f: scaler = pickle.load(f) with open('model_random_forest.pkl', 'rb') as f: model = pickle.load(f) def get_video_details(link): response = requests.get("https://tiktok-scraper7.p.rapidapi.com/", headers=headers, params={"url":link,"hd":"1"}) video_info = response.json() length = video_info['data']['duration'] video_like = int(video_info['data']['digg_count']) video_share = int(video_info['data']['share_count']) video_comment = int(video_info['data']['share_count']) video_view = int(video_info['data']['comment_count']) video_engagement = video_like+video_share+video_comment+video_view play_url = video_info['data']['play'] user_id = video_info['data']['author']['id'] music_id = video_info['data']['music_info']['id'] create_time = video_info['data']['create_time'] response = requests.get("https://tiktok-scraper7.p.rapidapi.com/user/info", headers=headers, params={"user_id":user_id}) user_info = response.json() follower = user_info['data']['stats']['followerCount'] total_likes = user_info['data']['stats']['heartCount'] total_video = user_info['data']['stats']['videoCount'] markdown_for_showing = f"""**Video Information** - **Likes**: {video_like} - **Shares**: {video_share} - **Comments**: {video_comment} - **Views**: {video_view} """ html_to_play = f'