add readme

This commit is contained in:
Keiran 2025-08-08 00:02:01 +01:00
parent 35d262868a
commit 889b7bb747

111
README.md Normal file
View File

@ -0,0 +1,111 @@
# 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
1. Go to [Google Cloud Console](https://console.cloud.google.com/).
2. Create a new project (or use an existing one).
3. Go to **APIs & Services → Library**.
4. Search for **YouTube Data API v3** and click **Enable**.
---
### 2. Create OAuth Credentials
1. Go to **APIs & Services → Credentials**.
2. Click **Create Credentials → OAuth client ID**.
3. If prompted, configure the **OAuth consent screen**:
- User type: **External**
- Add your Google account email under **Test users**
- Save
4. For **Application type**, choose **Desktop app**.
5. Name it something like `MD2YT`.
6. Download the JSON file and save it as `credentials.json` in the project folder.
---
### 3. Create a YouTube Channel (if you dont have one)
The API will fail with `youtubeSignupRequired` if your account doesnt have a channel.
1. Go to [YouTube](https://www.youtube.com/).
2. Click your profile picture → **Create a channel**.
3. Follow the prompts (no need to upload anything).
---
### 4. Prepare Your Playlist File
Create a `playlist.md` file in this format:
````markdown
# 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
```bash
go mod download
````
---
### 6. Run the Script
```bash
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.
- Youll 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.json` so you wont 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 didnt add your account as a **Test user** in the OAuth consent screen.
**Error:** `Error 401: Unauthorized, youtubeSignupRequired`
→ Your account doesnt have a YouTube channel. Create one before running the script.
---
## License
MIT
````