Skip to content

Commit 99bc2c5

Browse files
committed
fix: README bot naming changed. Trailing spaces removed.
1 parent 1ba7c67 commit 99bc2c5

File tree

4 files changed

+40
-25
lines changed

4 files changed

+40
-25
lines changed

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22

3-
# Instagram Bot Setup Guide
3+
# Video Downloader Bot Setup Guide
44

5-
This guide provides step-by-step instructions to install and run the Instagram bot on a Linux system.
6-
- Backend code uses [yt-dlp](https://github.com/yt-dlp/yt-dlp) which is released under [The Unlicense](https://unlicense.org/). All rights for yt-dlp belong to its respective authors.
5+
This guide provides step-by-step instructions to install and run the Video Downloader bot on a Linux system.
6+
- Backend code uses [yt-dlp](https://github.com/yt-dlp/yt-dlp) which is released under [The Unlicense](https://unlicense.org/). All rights for yt-dlp belong to its respective authors.
77
---
88

99
## 1. Install Required Packages
@@ -35,7 +35,7 @@ sudo nano /etc/systemd/system/insta-bot.service
3535
Add the following configuration to the file:
3636
```ini
3737
[Unit]
38-
Description=Instagram Bot Service
38+
Description=Video Downloader Bot Service
3939
After=network.target
4040

4141
[Service]
@@ -89,12 +89,12 @@ sudo systemctl status insta-bot.service
8989
Follow these simple steps to set up and use the bot:
9090

9191
### 1. Create Your Telegram Bot
92-
- Follow this guide to create your Telegram bot and obtain the bot token:
92+
- Follow this guide to create your Telegram bot and obtain the bot token:
9393
[How to Get Your Bot Token](https://www.freecodecamp.org/news/how-to-create-a-telegram-bot-using-python/).
9494

9595
### 2. Health Check
96-
- Verify the bot is running by sending a message with the trigger word:
97-
**`ботяра`**
96+
- Verify the bot is running by sending a message with the trigger word:
97+
**`ботяра`**
9898

9999
If the bot is active, it will respond accordingly.
100100

@@ -121,6 +121,7 @@ youtube shorts
121121
Example:
122122
```bash
123123
**https://www.youtube.com/watch?v=rxdu3whDVSM or with a space ** https://www.youtube.com/watch?v=rxdu3whDVSM
124-
```
124+
```
125+
125126
- Full list of supported sites here: [yt-dlp Supported Sites](https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md)
126127
---

logger.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
load_dotenv()
88
show_errors_in_console = os.getenv("DEBUG")
99

10+
1011
def print_logs(text):
1112
if show_errors_in_console:
1213
print(text)

main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""Download videos from tiktok, x(twitter), reddit, and insta reels"""
1+
"""Download videos from tiktok, x(twitter), reddit, youtube shorts, instagram reels and many more"""
2+
23
import os
34
import random
45
import json
@@ -66,7 +67,7 @@ async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE): #
6667
6768
This function processes text messages sent to the bot and determines the appropriate response
6869
based on the message content. It supports specific keywords and URLs, such as Instagram Reels
69-
and TikTok links, and attempts to download and send the corresponding video.
70+
, or other supported sites, and attempts to download and send the corresponding video.
7071
7172
Parameters:
7273
update (telegram.Update): Represents the incoming update from the Telegram bot.
@@ -76,7 +77,7 @@ async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE): #
7677
- If the message contains "ботяра" (case insensitive), responds with a random response
7778
from a predefined list.
7879
- If the message contains an Instagram Stories URL, informs the user that login is required.
79-
- If the message contains a supported URL (Instagram Reels, TikTok, Reddit, X/Twitter):
80+
- If the message contains a supported URL (Instagram Reels, Youtube Shorts, TikTok, Reddit, X/Twitter):
8081
- Downloads and optionally compresses the video
8182
- Sends the video back to the user via Telegram
8283
- Preserves spoiler tags if present in original message

video_utils.py

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
def compress_video(input_path):
1414
"""
1515
Compress video for 50MB with use of FFmpeg.
16-
16+
1717
Parameters:
1818
input_path (str): Path to original video.
1919
"""
@@ -30,13 +30,20 @@ def compress_video(input_path):
3030

3131
command = [
3232
"ffmpeg",
33-
"-i", input_path,
34-
"-b:v", f"{target_bitrate_kbps}k",
35-
"-vf", "scale=-2:720",
36-
"-c:v", "libx264",
37-
"-preset", "fast",
38-
"-c:a", "aac",
39-
"-b:a", "128k",
33+
"-i",
34+
input_path,
35+
"-b:v",
36+
f"{target_bitrate_kbps}k",
37+
"-vf",
38+
"scale=-2:720",
39+
"-c:v",
40+
"libx264",
41+
"-preset",
42+
"fast",
43+
"-c:a",
44+
"aac",
45+
"-b:a",
46+
"128k",
4047
"-y",
4148
temp_output
4249
]
@@ -56,9 +63,12 @@ def get_video_duration(video_path):
5663
"""
5764
command = [
5865
"ffprobe",
59-
"-v", "error",
60-
"-show_entries", "format=duration",
61-
"-of", "default=noprint_wrappers=1:nokey=1",
66+
"-v",
67+
"error",
68+
"-show_entries",
69+
"format=duration",
70+
"-of",
71+
"default=noprint_wrappers=1:nokey=1",
6272
video_path
6373
]
6474
try:
@@ -95,9 +105,11 @@ def download_video(url):
95105
temp_dir = tempfile.mkdtemp()
96106
command = [
97107
"yt-dlp", # Assuming yt-dlp is installed and in the PATH
98-
"-S", "vcodec:h264,fps,res,acodec:m4a",
108+
"-S",
109+
"vcodec:h264,fps,res,acodec:m4a",
99110
url,
100-
"-o", os.path.join(temp_dir, "%(id)s.%(ext)s")
111+
"-o",
112+
os.path.join(temp_dir, "%(id)s.%(ext)s")
101113
]
102114

103115
try:
@@ -121,7 +133,7 @@ def cleanup_file(video_path):
121133
"""
122134
Deletes a video file and its containing directory.
123135
124-
This function attempts to remove the specified video file and
136+
This function attempts to remove the specified video file and
125137
its parent directory. Logs are printed if debugging is enabled.
126138
127139
Parameters:

0 commit comments

Comments
 (0)