forked from Single-Developers/TikTok-DL-BOT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
121 lines (84 loc) ยท 5.79 KB
/
main.py
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
from telegram import ParseMode
from telegram.ext import (
Updater,
CommandHandler,
MessageHandler,
Filters
)
import requests
import os
import logging
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# TikTok Downloader API
API = 'https://api.single-developers.software/tiktok?url='
# Your BOT Token
BOT_TOKEN = os.getenv("BOT_TOKEN")
# TikTok Video URL Types , You Can Add More to This :)
TikTok_Link_Types= ['https://m.tiktok.com','https://vt.tiktok.com','https://tiktok.com','https://www.tiktok.com']
# ParseMode Type For All Messages
_ParseMode=ParseMode.MARKDOWN
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
def start_handler(update, context):
update.message.reply_sticker('CAACAgUAAxkBAAED9kRiDq_GkOHuRHPeVv4IRhsvy4NtbwACqQQAAncUyFftN80YUiyXnyME')
def about_handler(update, context):
update.message.reply_sticker('CAACAgUAAxkBAAED9kZiDq_LFrib38c7DYu3jNz3ebsolgACJAUAAuTb4FdKtjtZGQ2ukiME')
update.message.reply_text('[๐ TikTok Download API ๐](https://github.com/Single-Developers/API/blob/main/tiktok/Note.md)\n\n[๐ฅ SL Developers </> ๐ฑ๐ฐ](https://t.me/SL_Developers)',parse_mode=_ParseMode)
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# Download Task
def Download_Video(Link,update, context):
message=update.message
req=None
no_watermark=None
watermark=None
status_msg=message.reply_text('๐ DOแฏแแชOแฉแชIแG Video TO Sแฎแแฏแฎแ ....')
status_sticker=message.reply_sticker('CAACAgUAAxkBAAED9jhiDqYeGjENlCjftByz0au6n4YAASEAAnUEAALpa8lXL9cvxeTK-2AjBA')
# Getting Download Links Using API
try:
req=requests.get(API+Link).json()
no_watermark=req['no_watermark']
watermark= req['watermark']
print('Download Links Generated \n\n\n'+str(req)+'\n\n\n')
except:
print('Download Links Generate Error !!!')
status_msg.edit_text('โ๏ธ TikTok Downloader API Error !!! Report To Developer : @SL_Developers')
status_sticker.delete()
return
caption_text="""โโโโโโโโโโโโโโโโโ
โ
Successfully Downloaded {} Video ๐ฐ
๐ฐ Powerd by : [๐ TikTok Download API ๐](https://github.com/Single-Developers/API/blob/main/tiktok/Note.md)
[๐ฅ Single Developers </> ](https://t.me/SingleDevelopers) Corporation ยฉ๏ธ
โโโโโโโโโโโโโโโโโ"""
# Uploading Downloaded Videos to Telegram
print('Uploading Videos')
status_msg.edit_text('โ๏ธ ๐๐๐๐๐๐๐๐๐ ๐๐ ๐๐๐๐๐๐๐๐....')
message.reply_video(video=no_watermark,supports_streaming=True,caption=caption_text.format('No Watermark'),parse_mode=_ParseMode)
message.reply_video(video=watermark,supports_streaming=True,caption=caption_text.format('Watermark'),parse_mode=_ParseMode)
# Task Done ! So, Deleteing Status Messages
status_msg.delete()
status_sticker.delete()
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
def incoming_message_action(update, context):
message=update.message
if any(word in str(message.text) for word in TikTok_Link_Types):
context.dispatcher.run_async(Download_Video,str(message.text),update,context)
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
def main() -> None:
"""Run the bot."""
updater = Updater(BOT_TOKEN)
dispatcher = updater.dispatcher
# Commands Listning
dispatcher.add_handler(CommandHandler('start', start_handler, run_async=True))
dispatcher.add_handler(CommandHandler('about', about_handler, run_async=True))
# Message Incoming Action
dispatcher.add_handler( MessageHandler(Filters.text, incoming_message_action,run_async=True))
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main() # ๐ Start
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# Example For https://github.com/Single-Developers/API/blob/main/tiktok/Note.md
# https://t.me/SL_Developers
# https://t.me/SingleDevelopers
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ