├── Bot
├── __main__.py
├── group_strem.py
└── video_stream.py
├── Dockerfile
├── LICENSE
├── Procfile
├── README.md
├── app.json
├── requirements.txt
└── runtime.txt
/Bot/__main__.py:
--------------------------------------------------------------------------------
1 | from pyrogram import Client, idle
2 | import os
3 | from Bot.video_stream import app
4 | API_ID = os.environ.get("API_ID",12345)
5 | API_HASH = os.environ.get("API_HASH","")
6 | TOKEN = os.environ.get("TOKEN","")
7 |
8 | bot = Client(
9 | ":memory:",
10 | API_ID,
11 | API_HASH,
12 | bot_token=TOKEN,
13 | plugins=dict(root="Bot"),
14 | )
15 | bot.start()
16 | app.start()
17 | idle()
18 |
--------------------------------------------------------------------------------
/Bot/group_strem.py:
--------------------------------------------------------------------------------
1 | import re
2 | import os
3 | import time
4 | from pytgcalls import GroupCallFactory
5 | from pyrogram import Client, filters
6 | from pyrogram.types import Message
7 | # from py_youtube import ytdl
8 | from py_youtube import ytdl ,Data
9 |
10 | from Bot.video_stream import app
11 |
12 | group_call_factory = GroupCallFactory(app, GroupCallFactory.MTPROTO_CLIENT_TYPE.PYROGRAM)
13 | VIDEO_CALL = {}
14 |
15 |
16 |
17 | @Client.on_message(filters.group & filters.command(["stream"]))
18 | async def play(client, m: Message):
19 | if (m.reply_to_message):
20 | time.sleep(3)
21 | get =await client.get_chat_member(m.chat.id,m.from_user.id)
22 | status = get. status
23 | cmd_user = ["administrator","creator"]
24 | if status in cmd_user:
25 | link = m.reply_to_message.text
26 | youtube_regex = r"^(https?\:\/\/)?(www\.youtube\.com|youtu\.?be)\/.+"
27 | youtube_regex_match = re.match(youtube_regex, link)
28 | if youtube_regex_match:
29 | try:
30 | data = Data(link).data()
31 | video_url = ytdl(link).besturl()
32 | except Exception as e:
33 | await m.reply(f"**Error** -- `{e}`")
34 | return
35 | try:
36 | group_call = group_call_factory.get_group_call()
37 | await group_call.join(m.chat.id)
38 | await group_call.start_video(video_url,enable_experimental_lip_sync=True)
39 | VIDEO_CALL[m.chat.id] = group_call
40 | await client.send_photo(m.chat.id,photo=data["thumbnails"],caption =f"**Title :{data['title']}**\n**Views :{data['views']}**\n**Likes : {data['likes']}**",reply_to_message_id=m.message_id)
41 |
42 | except Exception as e:
43 | await m.reply(f"**Error** -- `{e}`")
44 | else:
45 | try:
46 | group_call = group_call_factory.get_group_call()
47 | await group_call.join(m.chat.id)
48 | await group_call.start_video(link,enable_experimental_lip_sync=True)
49 | VIDEO_CALL[m.chat.id] = group_call
50 | await m.reply("** Started Streaming!**")
51 | except Exception as e:
52 | await m.reply(f"**Error** -- `{e}`")
53 |
54 |
55 |
56 |
57 |
58 | @Client.on_message(filters.group & filters.command(["stopstream"]))
59 | async def stop (client, m: Message):
60 | time.sleep(3)
61 | get =await client.get_chat_member(m.chat.id,m.from_user.id)
62 | status = get. status
63 | cmd_user = ["administrator","creator"]
64 | if status in cmd_user:
65 | try:
66 | await VIDEO_CALL[m.chat.id].stop()
67 | await m.reply("** Stopped Streaming!**")
68 | except Exception as e:
69 | await m.reply(f"**Error** - `{e}`")
70 |
--------------------------------------------------------------------------------
/Bot/video_stream.py:
--------------------------------------------------------------------------------
1 | import re
2 | import os
3 | from pytgcalls import GroupCallFactory
4 | from pyrogram import Client, filters
5 | from pyrogram.types import Message
6 | # from py_youtube import ytdl
7 | from py_youtube import ytdl
8 |
9 | API_ID = os.environ.get("API_ID",12345)
10 | API_HASH = os.environ.get("API_HASH","")
11 | SESSION_NAME = os.environ.get("SESSION_NAME","")
12 | CHAT = os.environ.get("CHAT","")
13 | ADMIN = int(os.environ.get("ADMIN", 923943045))
14 |
15 | app = Client(SESSION_NAME, API_ID, API_HASH)
16 |
17 | group_call_factory = GroupCallFactory(app, GroupCallFactory.MTPROTO_CLIENT_TYPE.PYROGRAM)
18 | VIDEO_CALL = {}
19 |
20 | @Client.on_message(filters.private & filters.user(ADMIN) & filters.command(["start"]))
21 | async def start(client, m: Message):
22 | await m.reply("Hello Start Stream Video Using Command /play(reply_to_message) and /stop\n ")
23 |
24 |
25 | @Client.on_message(filters.private & filters.user(ADMIN) & filters.command(["play"]))
26 | async def play(client, m: Message):
27 | if (m.reply_to_message):
28 | link = m.reply_to_message.text
29 | youtube_regex = r"^(https?\:\/\/)?(www\.youtube\.com|youtu\.?be)\/.+"
30 | youtube_regex_match = re.match(youtube_regex, link)
31 | if youtube_regex_match:
32 | try:
33 | video_url = ytdl(link).besturl()
34 | except Exception as e:
35 | await m.reply(f"**Error** -- `{e}`")
36 | return
37 | try:
38 | group_call = group_call_factory.get_group_call()
39 | await group_call.join(CHAT)
40 | await group_call.start_video(video_url,enable_experimental_lip_sync=True)
41 | VIDEO_CALL[CHAT] = group_call
42 | await m.reply("**Started Streaming!**")
43 | except Exception as e:
44 | await m.reply(f"**Error** -- `{e}`")
45 |
46 |
47 | else:
48 | try:
49 | group_call = group_call_factory.get_group_call()
50 | await group_call.join(CHAT)
51 | await group_call.start_video(link,enable_experimental_lip_sync=True)
52 | VIDEO_CALL[CHAT] = group_call
53 | await m.reply("** Started Streaming!**")
54 | except Exception as e:
55 | await m.reply(f"**Error** -- `{e}`")
56 |
57 | @Client.on_message(filters.private & filters.user(ADMIN) & filters.command(["livestream"]))
58 | async def livestream(client, m: Message):
59 | if (m.reply_to_message):
60 | link = m.reply_to_message.text
61 | youtube_regex = r"^(https?\:\/\/)?(www\.youtube\.com|youtu\.?be)\/.+"
62 | youtube_regex_match = re.match(youtube_regex, link)
63 | if youtube_regex_match:
64 | try:
65 | video_url = ytdl(link).besturl()
66 | except Exception as e:
67 | await m.reply(f"**Error** -- `{e}`")
68 | return
69 | try:
70 | group_call = group_call_factory.get_group_call()
71 | await group_call.join(CHAT)
72 | await group_call.start_video(video_url,enable_experimental_lip_sync=False)
73 | VIDEO_CALL[CHAT] = group_call
74 | await m.reply("**Started Streaming!**")
75 | except Exception as e:
76 | await m.reply(f"**Error** -- `{e}`")
77 |
78 |
79 | else:
80 | try:
81 | group_call = group_call_factory.get_group_call()
82 | await group_call.join(CHAT)
83 | await group_call.start_video(link,enable_experimental_lip_sync=False)
84 | VIDEO_CALL[CHAT] = group_call
85 | await m.reply("** Started Streaming!**")
86 | except Exception as e:
87 | await m.reply(f"**Error** -- `{e}`")
88 |
89 |
90 |
91 |
92 | @Client.on_message(filters.private & filters.user(ADMIN) & filters.command(["stop"]))
93 | async def stop (client, m: Message):
94 | try:
95 | await VIDEO_CALL[CHAT].stop()
96 | await m.reply("** Stopped Streaming!**")
97 | except Exception as e:
98 | await m.reply(f"**Error** - `{e}`")
99 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM python:3.9
2 |
3 | RUN apt update && apt upgrade -y
4 | RUN apt install python3-pip -y
5 |
6 | COPY . /py
7 | WORKDIR /py
8 |
9 | RUN pip3 install --upgrade pip
10 | RUN pip3 install -U -r requirements.txt
11 |
12 | CMD python3 -m Bot
13 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 lokaman chendekar
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Procfile:
--------------------------------------------------------------------------------
1 | worker: python3 -m Bot
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Video Stream
2 | An Advanced VC Video Player created for playing video in the voice chats of Telegram Groups And Channel
3 |
4 | # Configs
5 | TOKEN - Get bot token from @BotFather
6 |
7 | API_ID - From my.telegram.org
8 |
9 | API_HASH - From my.telegram.org
10 |
11 | CHAT - Channel or Group username With @
12 |
13 | SESSION_NAME - Pyrogram String Session Get From [Here](https://replit.com/@SpEcHiDe/GenerateStringSession?v=1)
14 |
15 | TOKEN - Your Bot Token From [@BotFather](https://t.me/BotFather)
16 |
17 | ADMIN - Your User ID Get From [@MissRose_bot](https://t.me/MissRose_bot)
18 |
19 | # Commands
20 | =>> Video Player 🎧
21 | - /stream : Reply to Video or File That You Want To stream In Vc And You Can Try Lives
22 | - /livestream : To Steram YT Live
23 | - /start : Start the bot
24 | - /stop : To Stop The Current stream in vc
25 | - /stopstream : To Stop Streaming on Groups
26 |
27 | # 🚀 Deployment
28 |
29 | Deploy Your Own Bot ♥️ **Star 🌟 Fork 🍴 & Deploy**
30 |
31 | ### 💜 Railway - use at own risk
32 |
33 | [](https://railway.app/new/template?template=https://github.com/lntechnical2/videostream&envs=CHAT,SESSION_NAME,API_ID,API_HASH,TOKEN,ADMIN)
34 |
35 | ### 💜 Heroku - simplest way
36 |
37 | [](https://heroku.com/deploy?templatehttps://github.com/lntechnical2/videostream)
38 |
39 | Get pyrogram (p) `SESSION` from here:
40 | [](https://repl.it/@SpEcHiDe/GenerateStringSession)
41 |
42 | ### ⚔ Self-hosting (For Devs)
43 | ```sh
44 | apt update && apt upgrade -y
45 | apt install python3-pip -y
46 | pip3 install --upgrade pip
47 | pip3 install -U -r requirements.txt
48 | python3 -m Bot
49 |
50 | ```
51 | Dev
52 | - **Lokaman**
53 |
54 | ## Credits
55 |
56 | - **[MarshalX](https://github.com/MarshalX) ~ [pytgcalls](https://github.com/MarshalX/tgcalls)**
57 | - **[Dan](https://github.com/delivrance) for [Pyrogram](https://github.com/pyrogram/pyrogram)**
58 |
59 | # Support
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Video Stream ",
3 | "description": "Video Stream Telegram Bot",
4 | "keywords": [
5 | "Video Stream ",
6 | "pytgcalss"
7 | ],
8 | "repository": "https://github.com/lntechnical2/videostream",
9 | "success_url": "https://telegram.dog/lntechnical",
10 | "env": {
11 | "CHAT": {
12 | "description": "Channel or Group user Name With @",
13 | "value": ""
14 | },
15 | "SESSION_NAME": {
16 | "description": "Pyrogram String Session",
17 | "value": ""
18 | },
19 | "API_ID": {
20 | "description": "Your APP ID From my.telegram.org ",
21 | "value": ""
22 | },
23 | "API_HASH": {
24 | "description": "Your API Hash From my.telegram.org ",
25 | "value": ""
26 | },
27 | "TOKEN": {
28 | "description": "Your Bot Token From @BotFather",
29 | "value": ""
30 | },
31 | "ADMIN": {
32 | "description":"Add Your User ID"
33 | }
34 | },
35 | "buildpacks": [
36 | {
37 | "url": "heroku/python"
38 | }
39 | ]
40 | }
41 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | pyrogram==1.4.16
2 | pytgcalls==3.0.0.dev16
3 | TgCrypto
4 | py-youtube==1.1.2
5 |
--------------------------------------------------------------------------------
/runtime.txt:
--------------------------------------------------------------------------------
1 | python-3.9.7
2 |
--------------------------------------------------------------------------------