This repository contains a Python bot built using the Pyrogram library. The bot updates your Telegram channel's profile picture and name to display the music you are currently listening to from various music providers such as Spotify and Apple Music. The bot schedules updates every 5 minutes to ensure your channel is always showing the latest track. Features
- Python 3.7+
- Telgram User API
-
Clone the repository:
user@host:~$ git clone https://github.com/mazdakdev/TGNowPlaying --depth=1
-
Configure the Environment Variables:
user@host:~$ mv .env.sample .env && vim .env
-
Install Poetry using the official Docs.
-
Install the requirements and activate the virtual env's shell.
user@host:~$ poetry install && poetry shell
-
Run the Project
user@host:~$ bash start.sh
TODO:
TODO:
Contributions are, of course, welcome! Please open an issue or submit a pull request. For example, here is a step-by-step guide for adding a new provider:
- Create an Adapter for Your Provider:
Navigate to the
adapters/
directory. Create a new Python file for your service adapter, e.g.,your_service.py
. Implement a class that inherits fromProviderAdapter
and overrides thefetch_current_item
method.
from TGNowPlaying.adapters.base import ProviderAdapter
from typing import Optional, Tuple
class YourServiceAdapter(ProviderAdapter):
def __init__(self):
pass
async def fetch_current_item(self) -> Optional[Tuple[str, str, str]]:
title = do_sth_and_get_title()
message = f"Currently doing {title}"
image = do_sth_and_get_pfp()
return title, message, image
- Register Your Adapter in the Factory:
Open
factories/provider_factory.py
. Add an entry for your service in the_adapters
dictionary.
class ProviderAdapterFactory:
_adapters = {
"spotify": SpotifyAdapter,
"your_service": YourServiceAdapter, # Add your service here
}
....
- Test and Submit a PR :)
- Docs
- Apple Music
- Vscode presence (like Discord)