Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
libgnu committed Aug 31, 2021
0 parents commit e200ab0
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.9

RUN apt update && apt upgrade -y
RUN apt install python3-pip -y
RUN apt install ffmpeg -y

COPY . /innexia
WORKDIR /innexia

RUN pip3 install --upgrade pip
RUN pip3 install -U -r requirements.txt

CMD python3 -m player
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
worker: python3 -m player
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# VC Video Player

<a href="https://t.me/SiderzBot"><img src="https://img.shields.io/badge/Join-Telegram%20Channel-red.svg?logo=Telegram"></a>
<a href="t.me/SiderzChat"><img src="https://img.shields.io/badge/Join-Telegram%20Group-blue.svg?logo=telegram"></a>

# How To Host
[![Deploy+on+Railway](https://railway.app/button.svg)](https://railway.app/new/template?template=https://github.com/Sammy-XD/VcVideoPlayer&envs=API_ID,API_HASH,BOT_TOKEN,SESSION_NAME)


# Credit 🔥
```
|🇮🇳 Louis
|🇮🇳 Sammy
|🇮🇳 Blaze
```
- [MarshalX](https://github.com/MarshalX) for [pytgcalls](https://github.com/MarshalX/tgcalls)
- [Dan](https://github.com/delivrance) for [Pyrogram](https://github.com/pyrogram/pyrogram)


6 changes: 6 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import os

API_ID = int(os.getenv("API_ID", "6"))
API_HASH = os.getenv("API_HASH", "eb06d4abfb49dc3eeb1aeb98ae0f581e")
BOT_TOKEN = os.getenv("BOT_TOKEN")
SESSION_NAME = os.getenv("SESSION_NAME")
15 changes: 15 additions & 0 deletions player/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from pyrogram import Client, idle
from config import API_ID, API_HASH, BOT_TOKEN
from player.videoplayer import app

bot = Client(
":memory:",
API_ID,
API_HASH,
bot_token=BOT_TOKEN,
plugins=dict(root="player"),
)

bot.start()
app.start()
idle()
15 changes: 15 additions & 0 deletions player/start.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from pyrogram import Client, filters
from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup

@Client.on_message(filters.command("start"))
async def start(client, m: Message):
if m.chat.type == 'private':
await m.reply(f"**Hey, I'm a VC Video Player developed by Developers of** @SiderzBot \n\n**To use it:-** __ \n1) Add this Bot to your Group and Make it Admin \n2) Add__ @SiderzVideoPlayer __to your Group__ \n3) **Commands** : \n`/stream` (IN REPLY TO A VIDEO) \n`/stop`",
reply_markup=InlineKeyboardMarkup(
[[
InlineKeyboardButton(
"Support", url="t.me/SiderzChat")
]]
))
else:
await m.reply("**SiderzStreamBot is Alive! ✨**")
46 changes: 46 additions & 0 deletions player/videoplayer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import os
import asyncio
from pytgcalls import GroupCallFactory
from pyrogram import Client, filters
from pyrogram.types import Message
from config import API_ID, API_HASH, SESSION_NAME

app = Client(SESSION_NAME, API_ID, API_HASH)
group_call_factory = GroupCallFactory(app, GroupCallFactory.MTPROTO_CLIENT_TYPE.PYROGRAM)
VIDEO_CALL = {}


@Client.on_message(filters.command("stream"))
async def stream(client, m: Message):
replied = m.reply_to_message
if not replied:
await m.reply("`Reply to some Video!`")
elif replied.video or replied.document:
msg = await m.reply("`Downloading...`")
chat_id = m.chat.id
try:
video = await client.download_media(m.reply_to_message)
await msg.edit("`Converting...`")
os.system(f'ffmpeg -i "{video}" -vn -f s16le -ac 2 -ar 48000 -acodec pcm_s16le -filter:a "atempo=0.81" vid-{chat_id}.raw -y')
except Exception as e:
await msg.edit(f"**🚫 Error** - `{e}`")
await asyncio.sleep(5)
try:
group_call = group_call_factory.get_file_group_call(f'vid-{chat_id}.raw')
await group_call.start(chat_id)
await group_call.set_video_capture(video)
VIDEO_CALL[chat_id] = group_call
await msg.edit("**▶️ Started Streaming!**")
except Exception as e:
await msg.edit(f"**Error** -- `{e}`")
else:
await m.reply("`Reply to some Video!`")

@Client.on_message(filters.command("stop"))
async def stopvideo(client, m: Message):
chat_id = m.chat.id
try:
await VIDEO_CALL[chat_id].stop()
await m.reply("**⏹️ Stopped Streaming!**")
except Exception as e:
await m.reply(f"**🚫 Error** - `{e}`")
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
TgCrypto
ffmpeg-python
git+https://github.com/pyrogram/pyrogram@master
pytgcalls==3.0.0.dev10

0 comments on commit e200ab0

Please sign in to comment.