GithubHelp home page GithubHelp logo

subinps / musicplayer Goto Github PK

View Code? Open in Web Editor NEW
233.0 8.0 871.0 105 KB

Telegram Bot to play music in VoiceChat with Channel Support and autostarts Radio.

License: MIT License

Python 99.55% Dockerfile 0.29% Shell 0.17%

musicplayer's Introduction

Telegram Voice Chat Bot with Channel Support.

A Telegram Bot to Play Audio in Voice Chats With Youtube and Jio Saavn support. Supports Playing Music files from a telegram channel. Supports Live streaming from youtube.

Please fork this repository don't import code
Made with Python3
(C) @subinps
Copyright permission under MIT License
License -> https://github.com/subinps/MusicPlayer/blob/master/LICENSE

Deploy to Heroku

Deploy

NOTE: Make sure you have started a VoiceChat in your Group before deploying.

Deploy to VPS

git clone https://github.com/subinps/MusicPlayer
cd MusicPlayer
pip3 install -r requirements.txt
# <Create Variables appropriately>
python3 main.py

Vars:

  1. API_ID : Get From my.telegram.org
  2. API_HASH : Get from my.telegram.org
  3. BOT_TOKEN : @Botfather
  4. SESSION_STRING : Generate From here GenerateStringName
  5. CHAT : ID of Channel/Group where the bot plays Music.
  6. LOG_GROUP : Group to send Playlist, if CHAT is a Group
  7. ADMINS : ID of users who can use admin commands.
  8. STREAM_URL : Stream URL of radio station or a youtube live video to stream when the bot starts or with /radio command.You can also use a telegram channel as radio station. Just upload all you music files to a telegram channel and add the bot and user account in that channel and use chat_id of channel in STREAM_URL.You can also use any public telegram channels, in that case use the username of such channel in place of STREAM_URL (Bot being admin in public channel not required.) Some Streaming Links
  9. MAXIMUM_DURATION : Maximum duration of song to play.(Optional)
  10. REPLY_MESSAGE : A reply to those who message the USER account in PM. Leave it blank if you do not need this feature.
  11. ADMIN_ONLY : Pass Y If you want to make /play and /splay commands only for admins of CHAT. By default /play and /splay is available for all.
  • Enable the worker after deploy the project to Heroku
  • Bot will starts radio automatically in given CHAT with given STREAM_URL after deploy.(24*7 Music even if heroku restarts, radio stream restarts automatically.)
  • To play a song use /play as a reply to audio file or a youtube link.
  • Use /play to play song from youtube and /splay to play from JioSaavn or /cplay to play music from a telegram channel.
  • Use /help to know about other commands.

Features

  • Playlist, queue.
  • Supports Play from Youtube Playlist.
  • Change VoiceChat title to current playing song name.
  • Supports Live streaming from youtube
  • Supports both Jio Saavn and youtube to search songs.
  • Play from telegram file supported.
  • Play whole music files from a telegram channel.
  • Starts Radio after if no songs in playlist.
  • Automatically downloads audio for the first two tracks in the playlist to ensure smooth playing
  • Automatic restart even if heroku restarts.

Note

Contributions are welcomed, But Kanging and editing a few lines wont make you a Developer.
Fork the repo, Do not Import code.

Support

Connect Me On Telegram

Credits

musicplayer's People

Contributors

alberteinsteintg avatar spechide avatar subinps avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

musicplayer's Issues

key error

[download] Downloading video 24 of 25 [youtube] 50VNCymT-Cs: Downloading webpage [download] Downloading video 25 of 25 [youtube] EgBJmlPo8Xw: Downloading webpage [download] Finished downloading playlist: Mix - Witt Lowry - Into Your Arms (Lyrics) ft. Ava Max - [No Rap] Traceback (most recent call last): File "main.py", line 25, in <module> from config import Config File "/MusicPlayer/config.py", line 39, in <module> links.append(f['url']) KeyError: 'url'

Attributeerror

Bro error occer in repo in heroku

InputGroupCall(id=self.group_call.group_call.id, access_hash=self.group_call.group_call.access_hash)
2021-08-22T09:21:48.597532+00:00 app[worker.1]: AttributeError: 'NoneType' object has no attribute 'id'

add auto delete old bot messages

please add auto delete old messages by bot like when user added a new song & that song got played successfully then there is no need to show playlist.
the old playlist messages must got automatically deleted & only 1 valid playlist message always exist in the chat rather than its multiple copies.
For example i added an song & bot shows playlist that your song added. Now after some time either that song got finished OR someone else added an new song OR someone manually trigger /playlist command then that old message should auto delete & only 1 valid & uptodate one remains in chat.

same can be done with error/info messages like it should auto delete themselves after 120secs approx.

Implementing this could reduce the bot spam alot. I want to suggest some other UI improvements too but as of now this needed much & stability matters more than features.

At last thanks for making awesome music bot.

Improve player UI

I found that if the list of queued songs is Long then every time an new song started it pings all users whoever added an song in that list.

So my suggestion is to hide the queued or playlist of song list under an button. When an user click on that button only then full list will be shown.

The UI i am suggesting is kinda look like as described below:

Currently Playing Song

Songname: Name of song
Duration: song total timing
Requested_by: username

Below this text are total 3 buttons
In first line there must be 2 buttons.

• 1st button is Playlist which all group members can use.
• 2nd button is Skip button which only sudo users can use, for non sudo users show an popup message telling "you are not allowed to use this".
These above 2 buttons must be in 1 line

• Below these there is 3rd button named Player controls which opens the new sub menu which contains player functions like pause/resume, stop, mute/unmute, join/leave VC, etc . This button only can be usable by sudo users.

• Do add an Back button on each submenu level to go back on main player menu.

after doing floodwait fix commit now bot spams more floodwait logs after reboot

2021-08-31T13:14:43.370785+00:00 app[worker.1]: Task exception was never retrieved
2021-08-31T13:14:43.370793+00:00 app[worker.1]: future: <Task finished name='Task-520' coro=<GroupCall.__emit_join_payload_callback.._() done, defined at /usr/local/lib/python3.9/site-packages/pytgcalls/implementation/group_call.py:168> exception=FloodWait('[420 FLOOD_WAIT_X]: A wait of 38 seconds is required (caused by "phone.JoinGroupCall")')>
2021-08-31T13:14:43.370793+00:00 app[worker.1]: Traceback (most recent call last):
2021-08-31T13:14:43.370794+00:00 app[worker.1]: File "/usr/local/lib/python3.9/site-packages/pytgcalls/implementation/group_call.py", line 175, in _
2021-08-31T13:14:43.370794+00:00 app[worker.1]: await self.mtproto.join_group_call(
2021-08-31T13:14:43.370795+00:00 app[worker.1]: File "/usr/local/lib/python3.9/site-packages/pytgcalls/mtproto/pyrogram_bridge.py", line 186, in join_group_call
2021-08-31T13:14:43.370795+00:00 app[worker.1]: response = await self.client.send(
2021-08-31T13:14:43.370796+00:00 app[worker.1]: File "/usr/local/lib/python3.9/site-packages/pyrogram/methods/advanced/send.py", line 77, in send
2021-08-31T13:14:43.370796+00:00 app[worker.1]: r = await self.session.send(
2021-08-31T13:14:43.370797+00:00 app[worker.1]: File "/usr/local/lib/python3.9/site-packages/pyrogram/session/session.py", line 425, in send
2021-08-31T13:14:43.370797+00:00 app[worker.1]: return await self._send(data, timeout=timeout)
2021-08-31T13:14:43.370798+00:00 app[worker.1]: File "/usr/local/lib/python3.9/site-packages/pyrogram/session/session.py", line 395, in _send
2021-08-31T13:14:43.370798+00:00 app[worker.1]: RPCError.raise_it(result, type(data))
2021-08-31T13:14:43.370798+00:00 app[worker.1]: File "/usr/local/lib/python3.9/site-packages/pyrogram/errors/rpc_error.py", line 78, in raise_it
2021-08-31T13:14:43.370799+00:00 app[worker.1]: raise getattr(
2021-08-31T13:14:43.370799+00:00 app[worker.1]: pyrogram.errors.exceptions.flood_420.FloodWait: [420 FLOOD_WAIT_X]: A wait of 38 seconds is required (caused by "phone.JoinGroupCall")
2021-08-31T13:14:43.460770+00:00 app[worker.1]:
2021-08-31T13:14:43.460773+00:00 app[worker.1]: Traceback (most recent call last):
2021-08-31T13:14:43.460774+00:00 app[worker.1]: File "/usr/local/lib/python3.9/asyncio/locks.py", line 226, in wait
2021-08-31T13:14:43.460774+00:00 app[worker.1]: await fut
2021-08-31T13:14:43.460774+00:00 app[worker.1]: asyncio.exceptions.CancelledError
2021-08-31T13:14:43.460775+00:00 app[worker.1]:
2021-08-31T13:14:43.460775+00:00 app[worker.1]: During handling of the above exception, another exception occurred:
2021-08-31T13:14:43.460775+00:00 app[worker.1]:
2021-08-31T13:14:43.460775+00:00 app[worker.1]: Traceback (most recent call last):
2021-08-31T13:14:43.460776+00:00 app[worker.1]: File "/usr/local/lib/python3.9/asyncio/tasks.py", line 492, in wait_for
2021-08-31T13:14:43.460776+00:00 app[worker.1]: fut.result()
2021-08-31T13:14:43.460776+00:00 app[worker.1]: asyncio.exceptions.CancelledError
2021-08-31T13:14:43.460777+00:00 app[worker.1]:
2021-08-31T13:14:43.460777+00:00 app[worker.1]: The above exception was the direct cause of the following exception:
2021-08-31T13:14:43.460777+00:00 app[worker.1]:
2021-08-31T13:14:43.460777+00:00 app[worker.1]: Traceback (most recent call last):
2021-08-31T13:14:43.460778+00:00 app[worker.1]: File "/usr/local/lib/python3.9/site-packages/pyrogram/dispatcher.py", line 217, in handler_worker
2021-08-31T13:14:43.460778+00:00 app[worker.1]: await handler.callback(self.client, *args)
2021-08-31T13:14:43.460778+00:00 app[worker.1]: File "/usr/local/lib/python3.9/site-packages/pytgcalls/mtproto/pyrogram_bridge.py", line 63, in _process_update
2021-08-31T13:14:43.460779+00:00 app[worker.1]: await self._update_to_handlertype(update)
2021-08-31T13:14:43.460779+00:00 app[worker.1]: File "/usr/local/lib/python3.9/site-packages/pytgcalls/mtproto/pyrogram_bridge.py", line 69, in _process_group_call_participants_update
2021-08-31T13:14:43.460779+00:00 app[worker.1]: await self.group_call_participants_update_callback(wrapped_update)
2021-08-31T13:14:43.460780+00:00 app[worker.1]: File "/usr/local/lib/python3.9/site-packages/pytgcalls/implementation/group_call.py", line 134, in _group_call_participants_update_callback
2021-08-31T13:14:43.460780+00:00 app[worker.1]: await self.reconnect()
2021-08-31T13:14:43.460780+00:00 app[worker.1]: File "/usr/local/lib/python3.9/site-packages/pytgcalls/implementation/group_call.py", line 319, in reconnect
2021-08-31T13:14:43.460780+00:00 app[worker.1]: await asyncio.wait_for(self.__emit_join_payload_event.wait(), timeout=self.__ASYNCIO_TIMEOUT)
2021-08-31T13:14:43.460781+00:00 app[worker.1]: File "/usr/local/lib/python3.9/asyncio/tasks.py", line 494, in wait_for
2021-08-31T13:14:43.460781+00:00 app[worker.1]: raise exceptions.TimeoutError() from exc
2021-08-31T13:14:43.460781+00:00 app[worker.1]: asyncio.exceptions.TimeoutError

@subinps i think you should revert this commit its buggy

Critical stderr error

Hi i m facing an critical stderr error which doesn't let bot to play any new song. To generate this error you need to either use "/song blood water grandson" OR an long text string of songname. When that error happened after that bot is totally unusable, none other song can be played. only redeployment of bot fix that issue.

Here are some logs when i use "/play blood water grandson" command or for youtube songname with long text string or with unknown characters like // - || etc

Edited: same happened for this song https://www.youtube.com/watch?v=CihmFK_vg_I

./downloads/grandson - Blood // Water (Official Audio).raw: No such file or directory ffmpeg error (see stderr output for detail) Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/pyrogram/dispatcher.py", line 217, in handler_worker await handler.callback(self.client, *args) File "/MusicPlayer/plugins/player.py", line 222, in yplay await mp.download_audio(track) File "/MusicPlayer/utils.py", line 153, in download_audio loglevel='error' File "/usr/local/lib/python3.7/dist-packages/ffmpeg/_run.py", line 325, in run raise Error('ffmpeg', out, err) ffmpeg._run.Error: ffmpeg error (see stderr output for detail)

At last Thanks for making such a nice & stable bot, i hope soon necessary fixes arrives.

EDITED: I can confirm now, for me this error occurs for only those songs whom songname or title on youtube contains some special characters like / | \ etc etc. You can test yourself for further confirmation.

ATTENTION PLEASE!!!

How can we use this bot in channels which have more than 200 subscribers😐Cuz we can add the 1st 200 subscribers to a channel personally.So it's not possible to add bot to the channel with 200+ subscribers.

help me

hi and thanks for useful repo.
why when i play the yottube playlist, bot play only 25 files from playlist?
ia a way to play whole playlist?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.