6086897325
- Add playlist creation script with browser authentication - Support for 17 festival bands with top 3 songs each - Includes setup documentation and requirements - Fixes OAuth detection issue by adding dummy authorization header
3.5 KiB
3.5 KiB
Browser Authentication Setup
This guide will help you extract the necessary authentication cookies from your browser to use with ytmusicapi.
Step 1: Open YouTube Music
- Open your browser (Chrome or Firefox)
- Navigate to https://music.youtube.com
- Make sure you are logged in to your Google account
Step 2: Open Developer Tools
- Chrome/Edge: Press
F12orCtrl+Shift+I(Windows/Linux) /Cmd+Option+I(Mac) - Firefox: Press
F12orCtrl+Shift+I(Windows/Linux) /Cmd+Option+I(Mac)
Step 3: Go to Network Tab
- Click on the "Network" tab in Developer Tools
- If you don't see it, look for it in the tabs at the top of the developer tools panel
Step 4: Capture Network Requests
- Refresh the page (press
F5orCtrl+R/Cmd+R) - Wait for the page to load completely
- Look for requests to
music.youtube.comin the network list
Step 5: Find the Right Request
- Click on any request that goes to
music.youtube.com - Look for requests like:
browsegetBrowsesearch- Or any request that shows
music.youtube.comin the URL
Step 6: Copy Headers
- With a request selected, click on the "Headers" tab
- Scroll down to "Request Headers" section
- You need to copy the following headers:
Required Headers:
- Cookie - A long string starting with something like
VISITOR_INFO1_LIVE=... - User-Agent - Something like
Mozilla/5.0 (Windows NT 10.0; Win64; x64)...
Optional but Recommended:
- X-Goog-AuthUser - Usually
0or1 - Accept - Usually
*/*orapplication/json - Accept-Language - Your language preference
- Content-Type - Usually
application/json - x-origin - Usually
https://music.youtube.com
Step 7: Create browser.json
Create a file named browser.json in this directory with the following structure:
{
"User-Agent": "PASTE_YOUR_USER_AGENT_HERE",
"Accept": "*/*",
"Accept-Language": "en-US,en;q=0.9",
"Content-Type": "application/json",
"X-Goog-AuthUser": "0",
"x-origin": "https://music.youtube.com",
"Cookie": "PASTE_YOUR_COOKIE_HERE"
}
Replace:
PASTE_YOUR_USER_AGENT_HEREwith the User-Agent header value you copiedPASTE_YOUR_COOKIE_HEREwith the Cookie header value you copied
Important: The Cookie value is very long and contains sensitive information. Keep this file private and never commit it to version control.
Step 8: Verify
Your browser.json should look something like this (with your actual values):
{
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"Accept": "*/*",
"Accept-Language": "en-US,en;q=0.9",
"Content-Type": "application/json",
"X-Goog-AuthUser": "0",
"x-origin": "https://music.youtube.com",
"Cookie": "VISITOR_INFO1_LIVE=abc123...; YSC=xyz789...; [many more cookie values]"
}
Troubleshooting
- Can't find the Cookie header? Make sure you're looking at a request to
music.youtube.com, notyoutube.com - Authentication fails? Your cookies may have expired. Repeat the process to get fresh cookies
- Still having issues? Try using a different request from the network tab, or refresh the page and try again
Security Note
The browser.json file contains your authentication cookies. Anyone with access to this file can access your YouTube Music account. Keep it secure and never share it publicly.