Control your speakers with Telegram and play music from YouTube
If you've ever used Discord, you've probably heard of music bots that play music for you. All you had to do was just type "-p <track_name>" to listen to your favorite song. I also liked it, so I made the real one!
This is a kind of addition to the awesome Music Player Daemon. This script runs as a service on Raspberry Pi and allows you to play music from YouTube and control playback using Telegram.
List of available commands:
Make sure you have Python 3.7+ installed
$ sudo apt install mpd $ pip3 install https://github.com/raitonoberu/realmusicbot/archive/master.zip
Before running, you must configure your bot by editing the file ~/realmusicbot_settings.py:
$ nano ~/realmusicbot_settings.py
TOKEN = "<ENTER YOUR BOT TOKEN HERE>"
# 1. Enable global keyboard KEYBOARD = True # 2. Allows you to search radio (/radio <station>) RADIO_ON = True # 3. Allows you to search lyrics (/lyrics) # - Get your Genius API Token here: # - https://genius.com/api-clients GENIUS_TOKEN = "" # 4. Bot privatization (HIGHLY RECOMMENDED) # - Get your User ID using tg @userinfobot and add it to the list # - https://t.me/userinfobot # - If you leave it empty, everyone can use the bot ALLOWED_IDS =  # example: [123456789, 987641234]
Start MPD first:
$ sudo systemctl start mpd $ sudo systemctl enable mpd
There are two ways to run Real Music Bot. It's recommended to run it in a terminal first to make sure that it works.
Press Ctrl+C to close.
$ systemctl --user start realmusicbot $ systemctl --user enable realmusicbot
$ journalctl | grep realmusicbot
$ systemctl --user stop realmusicbot $ systemctl --user disable realmusicbot $ sudo rm ~/.config/systemd/user/realmusicbot.service $ sudo rm -r ~/realmusicbot* $ pip3 uninstall realmusicbot
Max Kellermann (MaxKellermann) for Music Player Daemon
FrankWang (eternnoir) for pyTelegramBotAPI
André P. Santos (andreztz) for pyradios
John W. Miller (johnwmillr) for LyricsGenius
"mps-youtube" organization for Pafy
Hitesh Kumar Saini (alexmercerind) for youtube-search-python