This script connects your YouTube Music listening activity to Discord, updating your Rich Presence to show what you're currently listening to. It uses the ytmusicapi for fetching song information and pypresence to communicate with Discord.
forgot to mention you have to have Python 3.13.7 or newer installed.
btw to gen the auth keys you need to cd into your python install directory's scripts and run the ytmusicapi.exe file from powershell like this: .\ytmusic oauth
- Automatic Updates: Automatically detects and displays the song you're playing.
- Album Art: Shows the song's album art directly on your profile.
- "Listen" Button: Adds a clickable button that links to the song on YouTube Music.
- Secure Authentication: Uses the official YouTube Music API via OAuth 2.0, so you don't have to provide your password.
Before you run the script, you need to set up two things: a Discord application and a Google Cloud project.
- Go to the Discord Developer Portal and log in.
- Click "New Application" in the top right corner and give it a name (e.g., "YouTube Music RPC").
- On the "General Information" page, copy the Application ID. This is your Discord
CLIENT_ID. - Navigate to "Rich Presence" -> "Art Assets".
- Upload a YouTube Music logo or any other image and name the asset
youtubemusic. This is what will appear as the icon next to the song information.
- Go to the Google Cloud Console and create or select a project.
- In the "APIs & Services" library, search for and enable the "YouTube Data API v3".
- Go to "Credentials" in the sidebar. Click "CREATE CREDENTIALS" and select "OAuth client ID".
- If prompted, configure the OAuth consent screen. Select "TV and Limited Input" as the application type, and create it.
- After creation, a pop-up will show your Client ID and Client secret. Copy both of these.
- Save the script as a Python file, for example,
rpc.py. - Edit the script and replace the placeholder values with the credentials you copied:
@dataclass class Config: CLIENT_ID: str = 'YOUR_DISCORD_APPLICATION_ID' # ... other settings YOUTUBE_CLIENT_ID: str = 'YOUR_GOOGLE_CLIENT_ID' YOUTUBE_CLIENT_SECRET: str = 'YOUR_GOOGLE_CLIENT_SECRET'
- Install the required libraries using pip:
pip install ytmusicapi pypresence
- Run the script from your terminal:
python rpc.py
The first time you run it, a browser window will open for you to authorize the application to access your YouTube Music account. Follow the prompts to complete the process. Once done, the script will create an oauth.json file to store your credentials and your Discord Rich Presence will update automatically.
