Skip to content

mazdakdev/TGNowPlaying

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TGNowPlaying

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

Requirements

  • Python 3.7+
  • Telgram User API

Preview

preview terminal

Deployment

  1. Clone the repository:

    user@host:~$ git clone https://github.com/mazdakdev/TGNowPlaying --depth=1
  2. Configure the Environment Variables:

    user@host:~$ mv .env.sample .env && vim .env
  3. Install Poetry using the official Docs.

  4. Install the requirements and activate the virtual env's shell.

    user@host:~$ poetry install && poetry shell
  5. Run the Project

    user@host:~$ bash start.sh

Deployment with Docker

TODO:

How to get Telegram User API

TODO:

Contributions

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:

  1. 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 from ProviderAdapter and overrides the fetch_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
  1. 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
    }
    ....
  1. Test and Submit a PR :)

Happy Listening! 🎶

TODO

  • Docs
  • Apple Music
  • Vscode presence (like Discord)

About

Share Your Current Playing Music in Telegram

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published