Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
NotReallyShikhar committed Dec 7, 2021
1 parent 9cb9edd commit 5f8ac75
Show file tree
Hide file tree
Showing 92 changed files with 8,759 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.env
*.log
.git/
.idea/
str.py
Procfile
README.md
downloads/
raw_files/
.gitignore
runtime.txt
__pycache__/
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.env
*.log
venv/
.idea/
*.session
raw_files/
downloads/
__pycache__/
*.session-journal
1 change: 1 addition & 0 deletions Aptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pv
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM nikolaik/python-nodejs:python3.10-nodejs17
RUN apt-get update \
&& apt-get install -y --no-install-recommends ffmpeg \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY . /app
WORKDIR /app
RUN pip3 install --no-cache-dir --upgrade --requirement requirements.txt


CMD bash start
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
worker: bash start
140 changes: 140 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<h1 align= center><b>⭐️ Yukki Music Bot ⭐️</b></h1>
<h3 align = center> A Telegram Music Bot written in Python using Pyrogram and Py-Tgcalls </h3>

<p align="center">
<a href="https://python.org"><img src="http://forthebadge.com/images/badges/made-with-python.svg" alt="made-with-python"></a>
<br>
<img src="https://img.shields.io/github/license/notreallyshikhar/YukkiMusicBot?style=for-the-badge" alt="LICENSE">
<img src="https://img.shields.io/github/contributors/notreallyshikhar/YukkiMusicBot?style=for-the-badge" alt="Contributors">
<img src="https://img.shields.io/github/repo-size/notreallyshikhar/YukkiMusicBot?style=for-the-badge" alt="Repository Size"> <br>
<img src="https://img.shields.io/github/forks/notreallyshikhar/YukkiMusicBot?style=for-the-badge" alt="Forks">
<img src="https://img.shields.io/github/stars/notreallyshikhar/YukkiMusicBot?style=for-the-badge" alt="Stars">
<img src="https://img.shields.io/github/watchers/notreallyshikhar/YukkiMusicBot?style=for-the-badge" alt="Watchers">
<img src="https://img.shields.io/github/commit-activity/w/notreallyshikhar/YukkiMusicBot?style=for-the-badge" alt="Commit Activity">
<img src="https://img.shields.io/github/issues/notreallyshikhar/YukkiMusicBot?style=for-the-badge" alt="Issues">
</p>

<h3 align="center">
Ready to use method
</h3>

<p align="center">
A Support Group and ready-to-use running instance of this bot can be found on Telegram <br>
<a href="https://t.me/YukkiRobot"> YukkiMusicBot </a> |
<a href="https://t.me/OfficialYukkiSupport"> YukkiSupport </a>
</p>

<h2 align="center">
Requirements
</h2>

<p align="center">
<a href="https://www.python.org/downloads/release/python-390/"> Python3.9 </a> |
<a href="https://docs.pyrogram.org/intro/setup#api-keys"> Telegram API Key </a> |
<a href="https://t.me/botfather"> Telegram Bot Token </a> |
<a href="https://telegra.ph/How-To-get-Mongodb-URI-04-06"> MongoDB URI </a>
</p>

<h2 align="center">
Stay Up-to-Date
</h2>

<p align="center"><img src="https://github.com/notreallyshikhar/YukkiMusicBot/blob/main/Utils/star.gif" alt="NotReallyShikhar Github" width="1000px" /></p>



<h2 align="center">
Install Locally Or On A VPS
</h2>


```console
shikhar@MacBook~ $ git clone https://github.com/notreallyshikhar/YukkiMusicBot
shikhar@MacBook~ $ cd YukkiMusicBot
shikhar@MacBook~ $ pip3 install -U -r requirements.txt
shikhar@MacBook~ $ cp sample.env .env
```

<h3 align="center">
Edit <b>.env</b> with your own values and Run Bot
</h3>

```console
shikhar@MacBook~ $ bash start
```
![alt text](https://github.com/notreallyshikhar/YukkiMusicBot/blob/main/Utils/screen.png)


<h2 align="center">
Other Deployment Methods
</h2>

<p align="center">
<a href="https://railway.app/new/template?template=https://github.com/notreallyshikhar/YukkiMusicBot&envs=BOT_TOKEN%2CAPI_ID%2CAPI_HASH%2CSESSION_STRING%2CSUDO_USERS%2COWNER_ID%2CDURATION_LIMIT%2CSUPPORT_CHANNEL%2CMONGO_DB_URI%2CLOG_GROUP_ID%2CASSISTANT_PREFIX%2CMUSIC_BOT_NAME%2CSUPPORT_GROUP&optionalEnvs=SUPPORT_CHANNEL%2CSUPPORT_GROUP"><img src="https://img.shields.io/badge/Deploy%20To%20Railway-blueviolet?style=for-the-badge&logo=railway" width="252""/</a>
<a href="https://dashboard.heroku.com/new?template=https://github.com/NotReallyShikhar/YukkiMusicBot"><img src="https://img.shields.io/badge/Deploy%20To%20Heroku-blueviolet?style=for-the-badge&logo=heroku" width="250""/</a>

</p>

<h2 align="center">
Generating Pyrogram Session
</h2>

<p align="center">
<a href="https://replit.com/@AaravxD/VsBSession#main.py"><img src="https://img.shields.io/badge/Generate%20On%20Repl-blueviolet?style=for-the-badge&logo=appveyor" width="245""/></a>
</p>

<h3 align="center">
OR
</h3>

```console
shikhar@MacBook~ $ git clone https://github.com/notreallyshikhar/YukkiMusicBot
shikhar@MacBook~ $ cd YukkiMusicBot
shikhar@MacBook~ $ pip3 install pyrogram TgCrypto
shikhar@MacBook~ $ python3 gen_session.py
```


<h2 align="center">
Config Vars
</h2>

1. `API_ID` : Assistant Account Telegram API_ID, get it from my.telegram.org
2. `API_HASH` : Assistant Account Telegram API_HASH, get it from my.telegram.org
3. `BOT_TOKEN` : Your Telegram Bot Token, get it from @Botfather (Make sure Inline is turned On)
4. `SESSION_STRING` : Pyrogram Session String of Assistant Account.
5. `MUSIC_BOT_NAME` : A name for your Music bot.
6. `MONGO_DB_URI` : MongoDB Database URL.
7. `LOG_GROUP_ID` : Chat ID where bot will log everything
8. `DURATION_LIMIT` : Duration Limit for Music (Mins)
9. `SUDO_USERS` : Sudo Users for Bot. (For multiple users seperate IDs with space)
10. `OWNER_ID`: Owner ID of Bot
11. `SUPPORT_GROUP` : Support Group Link (Leave blank if you don't have one)
12. `SUPPORT_CHANNEL` : Support Channel Link ( Leave blank if you don't have one)
13. `ASSISTANT_PREFIX` : Prefix for Assistant Commands


<h2 align="center">
Contact
</h2>

<p align="center">
<a href="https://t.me/OfficialYukki"><img src="https://img.shields.io/badge/Yukki%20Channel-blueviolet?style=for-the-badge&logo=telegram" width="200""/</a>
<a href="https://t.me/NotReallyShikhar"><img src="https://img.shields.io/badge/Contact%20Owner-blueviolet?style=for-the-badge&logo=telegram" width="202""/</a>
<a href="https://t.me/OfficialYukkiSupport"><img src="https://img.shields.io/badge/Yukki%20Support-blueviolet?style=for-the-badge&logo=telegram" width="195""/></a>
</p>



## License

Distributed under the [GNU General Public License v3.0 License.](https://github.com/notreallyshikhar/YukkiMusicBot/blob/main/LICENSE) See `LICENSE.md` for more information.

## Acknowledgements

Special thanks to these amazing projects which help power Yukki Music Bot:

- [Pyrogram](https://github.com/pyrogram/pyrogram)
- [Py-Tgcalls](https://github.com/pytgcalls/pytgcalls)
- [CallsMusic Team](https://github.com/Callsmusic)
- [WilliamButcherBot](https://github.com/TheHamkerCat/WilliamButcherBot)
Binary file added Utils/Playlist.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Utils/Query.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Utils/Result.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Utils/Telegram.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Utils/black.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Utils/blue.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Utils/finalfont.ttf
Binary file not shown.
Binary file added Utils/green.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Utils/grey.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Utils/orange.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Utils/pink.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Utils/red.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Utils/screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Utils/star.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Utils/yellow.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions Yukki/Core/Clients/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from config import API_HASH, API_ID, BOT_TOKEN, STRING
from pyrogram import Client

app = Client(
"YukkiMusicBot",
API_ID,
API_HASH,
bot_token=BOT_TOKEN,
)

userbot = Client(STRING, API_ID, API_HASH)
44 changes: 44 additions & 0 deletions Yukki/Core/Logger/Log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from config import LOG_GROUP_ID as _channel_id_

from Yukki.Core.Clients.cli import app, userbot

failure = "Make sure your bot is in your log channel and is promoted as an admin with full rights!"


async def log(_message_):
try:
await app.send_message(_channel_id_, f"<b>#LOGGER\n\n{_message_}</b>")
return bool(1)
except:
print(failure)
return


async def startup_send_new(_message_):
try:
entities = await app.send_message(
_channel_id_, f"<code>{_message_}</code>"
)
return entities
except:
print(failure)
return


async def startup_edit_last(_message_id, _message_):
try:
entities = await app.edit_message_text(
_channel_id_, _message_id.message_id, f"<code>{_message_}</code>"
)
return entities
except:
entities = await startup_send_new(_message_)
return entities


async def startup_delete_last(_message_id):
try:
await app.delete_messages(_channel_id_, _message_id.message_id)
return bool(1)
except:
pass
34 changes: 34 additions & 0 deletions Yukki/Core/PyTgCalls/Converter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import asyncio
from os import path


class FFmpegReturnCodeError(Exception):
pass


async def convert(file_path: str) -> str:
out = path.basename(file_path)
out = out.split(".")
out[-1] = "raw"
out = ".".join(out)
out = path.basename(out)
out = path.join("raw_files", out)

if path.isfile(out):
return out

try:
proc = await asyncio.create_subprocess_shell(
f"ffmpeg -y -i {file_path} -f s16le -ac 1 -ar 48000 -acodec pcm_s16le {out}",
asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)

await proc.communicate()

if proc.returncode != 0:
raise FFmpegReturnCodeError("FFmpeg did not return 0")

return out
except:
raise FFmpegReturnCodeError("FFmpeg did not return 0")
94 changes: 94 additions & 0 deletions Yukki/Core/PyTgCalls/Downloader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
from os import path

from yt_dlp import YoutubeDL

from Yukki import MUSIC_BOT_NAME

ytdl = YoutubeDL(
{
"outtmpl": "downloads/%(id)s.%(ext)s",
"format": "bestaudio/best",
"geo_bypass": True,
"nocheckcertificate": True,
"quiet": True,
"no_warnings": True,
}
)


def download(videoid: str, mystic, title) -> str:
flex = {}
url = f"https://www.youtube.com/watch?v={videoid}"

def my_hook(d):
if d["status"] == "downloading":
percentage = d["_percent_str"]
per = (str(percentage)).replace(".", "", 1).replace("%", "", 1)
per = int(per)
eta = d["eta"]
speed = d["_speed_str"]
size = d["_total_bytes_str"]
bytesx = d["total_bytes"]
if str(bytesx) in flex:
pass
else:
flex[str(bytesx)] = 1
if flex[str(bytesx)] == 1:
flex[str(bytesx)] += 1
try:
if eta > 2:
mystic.edit(
f"**{MUSIC_BOT_NAME} Downloader**\n\n**Title:** {title[:50]}:\n**FileSize:** {size}\n\n**<u>Downloaded:</u>**\n**Speed:** {speed}\n**ETA:** {eta} Seconds\n\n\n{percentage} ▓▓▓▓▓▓▓▓▓▓▓▓ 100%"
)
except Exception as e:
pass
if per > 250:
if flex[str(bytesx)] == 2:
flex[str(bytesx)] += 1
if eta > 2:
mystic.edit(
f"**{MUSIC_BOT_NAME}Downloader**\n\n**Title:** {title[:50]}:\n**FileSize:** {size}\n\n**<u>Downloaded:</u>**\n**Speed:** {speed}\n**ETA:** {eta} Seconds\n\n\n{percentage} ███▓▓▓▓▓▓▓▓▓ 100%"
)
if per > 500:
if flex[str(bytesx)] == 3:
flex[str(bytesx)] += 1
if eta > 2:
mystic.edit(
f"**{MUSIC_BOT_NAME} Downloader**\n\n**Title:** {title[:50]}:\n**FileSize:** {size}\n\n**<u>Downloaded:</u>**\n**Speed:** {speed}\n**ETA:** {eta} Seconds\n\n\n{percentage} ██████▓▓▓▓▓▓ 100%"
)
if per > 800:
if flex[str(bytesx)] == 4:
flex[str(bytesx)] += 1
if eta > 2:
mystic.edit(
f"**{MUSIC_BOT_NAME} Downloader**\n\n**Title:** {title[:50]}:\n**FileSize:** {size}\n\n**<u>Downloaded:</u>**\n**Speed:** {speed}\n**ETA:** {eta} Seconds\n\n\n{percentage} ██████████▓▓ 100%"
)
if d["status"] == "finished":
try:
taken = d["_elapsed_str"]
except Exception as e:
taken = "00:00"
size = d["_total_bytes_str"]
mystic.edit(
f"**{MUSIC_BOT_NAME} Downloader**\n\n**Title:** {title[:50]}:\n\n100% ████████████100%\n\n**Time Taken:** {taken} Seconds\n\nConverting Audio[FFmpeg Process]"
)

ydl_optssx = {
"format": "bestaudio/best",
"outtmpl": "downloads/%(id)s.%(ext)s",
"geo_bypass": True,
"nocheckcertificate": True,
"quiet": True,
"no_warnings": True,
}
try:
x = YoutubeDL(ydl_optssx)
x.add_progress_hook(my_hook)
dloader = x.download([url])
except Exception as y_e:
return print(y_e)
else:
dloader
info = x.extract_info(url, False)
xyz = path.join("downloads", f"{info['id']}.{info['ext']}")
return xyz
Loading

0 comments on commit 5f8ac75

Please sign in to comment.