Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions AutomationScripts/Telegram Instagram Uploader/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Telegram Instagram Uploader

## Aim
Automation/simplification for Humans 🤷‍♂🤖

## Purpose

To Allow Telegram Users, to easily Upload Videos saved on Telegram to Instagram Reels.


### Libraries Used
- `Telethon` : for connecting with Telegram
- `Instagrapi` : for connecting with Instagram
- `Cryptg` : Optional Requirement of Telethon, to speed up download process..
- `moviepy` : required by Instagrapi, for video processing...


## Workflow of the Project
- When You send your Video/gif to chat filled in `TG_CHATIDS`.
- Bot will download that Video to its local.
- And will try to Upload Video to Instagram Reels from Account whose credentials are filed in `INSTAGRAM_USERNAME` and `INSTAGRAM_PASSWORD`.
- And Done!
- `settings.json` will be created to save Instagram Login Settings, to avoid Multiple Logins.
- Similarly, Telethon creates a `.session` file to save the auth.

## Setup instructions
- Just You need is Install [`python`](https://www.python.org) on your device.
- Clone the Project and Move to Current Directory.

## Compilation Steps
- Check and fill the Required Values in `telegram_instagram.py`
- If Required Vars are not Filed, you will be asked to Fill Required Vars in Input..
- Install Requirements
- `pip3 install -r requirements.txt`
- Run the main Script
- `python3 telegram_instagram.py`

## Output
### AT TELEGRAM
<img src="./Images/output1.jpg">
<hr>

#### AT INSTAGRAM
<img src="./Images/output2.jpg">


## Author(s)
- [New-dev0](https://github.com/New-dev0)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
instagrapi==1.14.4
telethon==1.23.0
cryptg==0.2.post4
moviepy==1.0.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# --- imports --- #
import os
import logging
from instagrapi import Client
from telethon import TelegramClient
from telethon.events import NewMessage

# --- Required Vars --- #
INSTAGRAM_USERNAME = "" or input("Enter Your Instagr Username : ")
INSTAGRAM_PASSWORD = "" or input("Enter your Instagram Password :")

API_ID = 6 # Telegram API ID
API_HASH = "eb06d4abfb49dc3eeb1aeb98ae0f581e" # Telegram API HASH
TG_BOT_TOKEN = "" or input("Enter Telegram Bot Token") # Telegram BOT_TOKEN
TG_CHATIDS = [] or [
int(chat) for chat in input("Enter Chat Ids : ")
] # List of Telegram Chat Ids

# ------ Main ------ #
logging.basicConfig(level=logging.INFO) # set logging level

# Create Instagram Client
settings = "settings.json" if os.path.exists("settings.json") else None
InstaClient = Client()

# So That, it doesnt create session again and again
if settings:
InstaClient.load_settings(settings)
InstaClient.login(INSTAGRAM_USERNAME, INSTAGRAM_PASSWORD)
else:
InstaClient.login(INSTAGRAM_USERNAME, INSTAGRAM_PASSWORD)
InstaClient.dump_settings("settings.json")

# Creatimg Telegram Client
Client = TelegramClient("Tele-Insta-BOT", api_id=API_ID, api_hash=API_HASH)
Client = Client.start(bot_token=TG_BOT_TOKEN)


# Function/Handler to get Telegram Event Update with Video And Chat Filter.
@Client.on(NewMessage(chats=TG_CHATIDS, func=lambda e: e.video))
async def upload_to_insta(event):
msg = await event.reply("Downloading Video...")
caption = event.message.message or "#Auto"
file = await event.download_media()
msg = await msg.edit("Uploading Now...")
try:
video = InstaClient.clip_upload(file, caption=caption)
except Exception as ER:
print(ER)
os.remove(file)
return await msg.edit(str(ER))
m = "Uploaded to Instagram\n"
m += f"https://instagram.com/p/{video.code}"
await msg.edit(m)
os.remove(file) # remove file after use..


with Client:
Client.run_until_disconnected()
# Start And Loop Telegram Client