From 889b7bb747172498f0a1b866c8c2188621d1ea03 Mon Sep 17 00:00:00 2001 From: Keiran Date: Fri, 8 Aug 2025 00:02:01 +0100 Subject: [PATCH] add readme --- README.md | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..d935699 --- /dev/null +++ b/README.md @@ -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 don’t have one) + +The API will fail with `youtubeSignupRequired` if your account doesn’t 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. +- 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.json` so 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 +````