MD2YT
Small go script to declaratively define a YouTube (Music) playlist through Markdown formatting with support for multiple playlists within a single file. Requires a lot of setup, but once done, it is very easy to maintain.
Requirements
- Go
- A Google account with a YouTube channel (required by the API)
- YouTube Data API v3 enabled in Google Cloud
- OAuth 2.0 credentials (Desktop App type)
Setup
1. Enable the YouTube Data API
- Go to Google Cloud Console.
- Create a new project (or use an existing one).
- Go to APIs & Services → Library.
- Search for YouTube Data API v3 and click Enable.
2. Create OAuth Credentials
- Go to APIs & Services → Credentials.
- Click Create Credentials → OAuth client ID.
- If prompted, configure the OAuth consent screen:
- User type: External
- Add your Google account email under Test users
- Save
- For Application type, choose Desktop app.
- Name it something like
MD2YT. - Download the JSON file and save it as
credentials.jsonin the project folder.
3. Create a YouTube Channel (if you don’t have one)
The API will fail with youtubeSignupRequired if your account doesn’t have a channel.
- Go to YouTube.
- Click your profile picture → Create a channel.
- Follow the prompts (no need to upload anything).
4. Prepare Your Playlist File
Create a playlist.md file in this format:
# Playlists
## My Playlist Name
- [Song Title - Artist](https://music.youtube.com/watch?v=VIDEO_ID)
- [Another Song](https://music.youtube.com/watch?v=VIDEO_ID)
## Another Playlist
- [Track 1](https://music.youtube.com/watch?v=VIDEO_ID)
You can have as many ## Playlist Name sections as you want.
5. Install Dependencies
go mod download
6. Run the Script
go run main.go
On first run:
- The script will print a Google login URL.
- Open it in your browser, log in, and approve access.
- You’ll be redirected to
http://localhost/?code=...— copy the code from the URL and paste it into the terminal. - The script will save your token to
token.jsonso you won’t have to log in again.
Troubleshooting
Error: Unable to parse client secret file to config: missing redirect URL
→ You downloaded a "Web application" OAuth file. Create a Desktop app OAuth client instead.
Error: Error 403: access_denied
→ You didn’t add your account as a Test user in the OAuth consent screen.
Error: Error 401: Unauthorized, youtubeSignupRequired
→ Your account doesn’t have a YouTube channel. Create one before running the script.
License
MIT