Spaces:
Runtime error
Runtime error
victorisgeek
commited on
Commit
•
b788eae
1
Parent(s):
ee11f1a
Rename lib/launcher.py to app.py
Browse files- app.py +51 -0
- lib/launcher.py +0 -13
app.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from download import TDLALL, IDLALL # Import your TikTok downloader methods
|
3 |
+
from sendT import sendTelmain # Import Telegram bot sending logic
|
4 |
+
import os
|
5 |
+
|
6 |
+
# Function to handle downloading and returning video file path
|
7 |
+
def download_video(url):
|
8 |
+
IDLALL() # Initialize download (assuming this sets up any necessary configurations)
|
9 |
+
TDLALL(url) # Download the video using the URL
|
10 |
+
|
11 |
+
# Assuming the downloaded video is saved in './vids/' directory
|
12 |
+
video_files = os.listdir('./vids/')
|
13 |
+
if video_files:
|
14 |
+
latest_video = './vids/' + video_files[-1] # Get the latest downloaded video
|
15 |
+
return latest_video # Return the path to the video file
|
16 |
+
return None
|
17 |
+
|
18 |
+
# Gradio Interface
|
19 |
+
def interface(url):
|
20 |
+
video_path = download_video(url)
|
21 |
+
if video_path:
|
22 |
+
# Return the video for preview in Gradio
|
23 |
+
return video_path
|
24 |
+
else:
|
25 |
+
return "Error downloading video."
|
26 |
+
|
27 |
+
def send_to_telegram():
|
28 |
+
# Send the video to the Telegram bot
|
29 |
+
sendTelmain()
|
30 |
+
return "Videos sent to Telegram bot."
|
31 |
+
|
32 |
+
# Create Gradio interface
|
33 |
+
with gr.Blocks() as demo:
|
34 |
+
gr.Markdown("# TikTok Video Downloader")
|
35 |
+
|
36 |
+
with gr.Row():
|
37 |
+
url_input = gr.Textbox(label="TikTok Video URL", placeholder="Enter TikTok video URL here")
|
38 |
+
|
39 |
+
with gr.Row():
|
40 |
+
download_button = gr.Button("Download Video")
|
41 |
+
send_button = gr.Button("Send to Telegram Bot")
|
42 |
+
|
43 |
+
with gr.Row():
|
44 |
+
video_preview = gr.Video(label="Downloaded Video Preview")
|
45 |
+
|
46 |
+
download_button.click(fn=interface, inputs=url_input, outputs=video_preview)
|
47 |
+
send_button.click(fn=send_to_telegram, inputs=None, outputs=None)
|
48 |
+
|
49 |
+
# Launch Gradio App
|
50 |
+
if __name__ == "__main__":
|
51 |
+
demo.launch()
|
lib/launcher.py
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
from download import TDLALL
|
2 |
-
from download import IDLALL
|
3 |
-
from sendT import sendTelmain
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
def launch():
|
8 |
-
IDLALL()
|
9 |
-
TDLALL()
|
10 |
-
#sendTelmain()
|
11 |
-
|
12 |
-
if __name__ == '__main__':
|
13 |
-
launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|