File size: 1,717 Bytes
b788eae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from download import TDLALL, IDLALL  # Import your TikTok downloader methods
from sendT import sendTelmain  # Import Telegram bot sending logic
import os

# Function to handle downloading and returning video file path
def download_video(url):
    IDLALL()  # Initialize download (assuming this sets up any necessary configurations)
    TDLALL(url)  # Download the video using the URL

    # Assuming the downloaded video is saved in './vids/' directory
    video_files = os.listdir('./vids/')
    if video_files:
        latest_video = './vids/' + video_files[-1]  # Get the latest downloaded video
        return latest_video  # Return the path to the video file
    return None

# Gradio Interface
def interface(url):
    video_path = download_video(url)
    if video_path:
        # Return the video for preview in Gradio
        return video_path
    else:
        return "Error downloading video."

def send_to_telegram():
    # Send the video to the Telegram bot
    sendTelmain()
    return "Videos sent to Telegram bot."

# Create Gradio interface
with gr.Blocks() as demo:
    gr.Markdown("# TikTok Video Downloader")
    
    with gr.Row():
        url_input = gr.Textbox(label="TikTok Video URL", placeholder="Enter TikTok video URL here")
    
    with gr.Row():
        download_button = gr.Button("Download Video")
        send_button = gr.Button("Send to Telegram Bot")
    
    with gr.Row():
        video_preview = gr.Video(label="Downloaded Video Preview")
    
    download_button.click(fn=interface, inputs=url_input, outputs=video_preview)
    send_button.click(fn=send_to_telegram, inputs=None, outputs=None)

# Launch Gradio App
if __name__ == "__main__":
    demo.launch()