forked from TheDarkW3b/instagram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
70 lines (60 loc) · 3.02 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
# -*- coding: utf-8 -*-
# DONT_REMOVE_THIS
# TheDarkW3b (c)
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext
from telegram import ParseMode, Update
import logging
import requests
import json
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
#Logger Setup
logger = logging.getLogger(__name__)
TOKEN = "6099343372:AAEeZlUfpYLFCdyipCBBA4G3UflG12CJuAA"
def download(update: Update, context: CallbackContext):
message = update.effective_message
instagram_post = message.text
if instagram_post=="/start":
context.bot.send_chat_action(chat_id=update.message.chat_id, action="typing")
update.message.reply_text("❤️ Thanks For Using Me Just Send Me The Link In Below Format \n🔥 Format :- https://www.instagram.com/p/B4zvXCIlNTw/ \nVideos Must Be Less Then 20MB, For Now It Cannot Support Long IGTV Videos \n\n<b>Support Group :-</b> @Technology_Arena \n<b>🌀 Source</b> \nhttps://github.com/TheDarkW3b/instagram", parse_mode=ParseMode.HTML, disable_web_page_preview=True)
else:
pass
if "instagram.com" in instagram_post:
changing_url = instagram_post.split("/")
url_code = changing_url[4]
url = f"https://instagram.com/p/{url_code}?__a=1"
try:
global checking_video
visit = requests.get(url).json()
checking_video = visit['graphql']['shortcode_media']['is_video']
except:
context.bot.sendMessage(chat_id=update.message.chat_id, text="Send Me Only Public Instagram Posts ⚡️")
if checking_video==True:
try:
video_url = visit['graphql']['shortcode_media']['video_url']
context.bot.send_chat_action(chat_id=update.message.chat_id, action="upload_video")
context.bot.sendVideo(chat_id=update.message.chat_id, video=video_url)
except:
pass
elif checking_video==False:
try:
post_url = visit['graphql']['shortcode_media']['display_url']
context.bot.send_chat_action(chat_id=update.message.chat_id, action="upload_photo")
context.bot.sendPhoto(chat_id=update.message.chat_id, photo=post_url)
except:
pass
else:
context.bot.send_chat_action(chat_id=update.message.chat_id, action="typing")
context.bot.sendMessage(chat_id=update.message.chat_id, text="I Cant Send You Private Posts :-( ")
else:
context.bot.sendMessage(chat_id=update.message.chat_id, text="Kindly Send Me Public Instagram Video/Photo Url")
def main():
updater = Updater(TOKEN, use_context=True)
dp = updater.dispatcher
logger.info("Setting Up MessageHandler")
dp.add_handler(MessageHandler(Filters.text, download))
updater.start_polling()
logging.info("Starting Long Polling!")
updater.idle()
if __name__ == "__main__":
main()