Create M3U Playlists from YouTube in Seconds
How to Use IINA and yt-dlp to Turn Any YouTube Playlist or Mix into a Local M3U Playlist on macOS, Linux, or Windows
If you ever wanted to create a playlist you can play locally in IINA or VLC using your favourite YouTube mixes or playlists, this guide will walk you through a simple setup using yt-dlp
, a tiny shell function, and IINA. This works on macOS, Linux, and Windows (WSL or Git Bash).
Why Use IINA Instead of a Browser for Watching YouTube?
First off, IINA automatically skips ads and sponsor segments, without the need for YouTube Premium. You also get complete control over playback quality and formats—choose exactly how you want to watch or listen. And guess what? It even works better with proxies or VPNs, making it easier to access videos that are blocked in your region.
Want to watch offline? IINA handles video and playlist downloads like a pro. And since it’s a native macOS app, it feels faster and more stable than streaming in a browser. You’ll experience fewer playback hiccups and better retry support if your connection drops.
Now, here’s where things get really exciting: audio. IINA connects more directly with your Mac’s audio system (Core Audio), which means it can take better advantage of the internal DAC (digital-to-analog converter). Compared to browsers—which run in more restricted, layered environments—IINA can deliver audio with less delay and potentially better quality. It supports things like higher sample rates, surround sound downmixing, and even some spatial audio features (though that part’s still in the works).
In summary, while your Mac’s DAC doesn’t change depending on the app, IINA’s direct, optimised audio path can give you a clearer, more accurate sound than a browser. So, if you’re into quality and control, IINA is definitely worth checking out.
🧰 Requirements
You’ll need the following tools installed:
IINA – a modern macOS media player (or VLC for cross-platform)
yt-dlp
– a powerful YouTube downloaderjq
– for parsing JSONA shell environment (Terminal on macOS/Linux, Git Bash or WSL on Windows)
🛠️ Step-by-Step Installation
macOS
Install Homebrew (if not installed):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install required tools:
brew install yt-dlp jq
Download IINA:
Visit https://iina.io and drag it to Applications.
Linux (Ubuntu/Debian-based)
Install dependencies:
sudo apt update
sudo apt install yt-dlp jq
Install a media player:
Use VLC or MPV, or build IINA manually if adventurous (macOS-only by default).
Windows (WSL or Git Bash)
Install Git Bash: https://git-scm.com/downloads
Install yt-dlp and jq via Chocolatey or manually:
choco install yt-dlp jq
Or download:
yt-dlp.exe
jq.exe
Use IINA Alternative: Install VLC or MPV for playback.
🧩 Adding the Function
🖥️ macOS & Linux – Bash Script
For macOS/Linux, place the following function in your ~/.bashrc
, ~/.zshrc
, or ~/.bash_profile
:
yt-inna-pl() {
if [[ -z "$1" ]]; then
echo "Usage: yt-inna-pl <YouTube_Mix_or_Playlist_URL> [basename]"
return 1
fi
local url="$1"
local base="${HOME}/Downloads/${2:-playlist}"
yt-dlp --flat-playlist -J "$url" > "${base}.json" || { echo "yt-dlp failed"; return 1; }
jq -r '.entries[].id' "${base}.json" > "${base}_ids.txt" || { echo "jq failed"; return 1; }
sed -e 's_^_https://www.youtube.com/watch?v=_' "${base}_ids.txt" > "${base}.txt"
echo "#EXTM3U" > "${base}.m3u" cat "${base}.txt" >> "${base}.m3u"
rm -f "${base}.txt"
echo "Playlist file created: ${base}.m3u"
}
Add it to your profile:
echo 'source ~/yt-inna-pl.sh' >> ~/.bashrc # or ~/.zshrc
source ~/.bashrc # or source ~/.zshrc
🪟 Windows – Batch Script (.bat)
For Windows users using Command Prompt or double-clickable .bat files, you can use:
@echo off
setlocal enabledelayedexpansion
if "%~1"=="" (
echo Usage: yt-inna-pl.bat [YouTube_URL] [basename]
exit /b 1
)
set "URL=%~1"
set "BASE=%USERPROFILE%\Downloads\%~2"
if "%~2"=="" set "BASE=%USERPROFILE%\Downloads\playlist"
yt-dlp --flat-playlist -J "%URL%" > "%BASE%.json" || (
echo yt-dlp failed
exit /b 1
)
jq -r ".entries[].id" "%BASE%.json" > "%BASE%_ids.txt" || (
echo jq failed
exit /b 1
)
(for /f "usebackq delims=" %%i in ("%BASE%_ids.txt") do (
echo https://youtube.com/watch?v=%%i
)) > "%BASE%.txt"
(
echo #EXTM3U
type "%BASE%.txt"
) > "%BASE%.m3u"
del "%BASE%.txt"
echo Playlist file created: %BASE%.m3u
Place yt-dlp.exe and jq.exe in the same folder or ensure they're in your PATH.
💻 Windows – PowerShell Script
param (
[string]$url,
[string]$basename = "playlist"
)
if (-not $url) {
Write-Host "Usage: yt-inna-pl.ps1 -url <YouTube_URL> [-basename name]"
exit 1
}
$base = "$env:USERPROFILE\Downloads\$basename"
yt-dlp --flat-playlist -J $url | Out-File "${base}.json"
if ($LASTEXITCODE -ne 0) {
Write-Host "yt-dlp failed"
exit 1
}
$ids = Get-Content "${base}.json" | ConvertFrom-Json | Select-Object -ExpandProperty entries | ForEach-Object { $_.id }
$urls = $ids | ForEach-Object { "https://youtube.com/watch?v=$_" }
$urls | Out-File "${base}.txt"
"#EXTM3U" | Out-File "${base}.m3u"
Get-Content "${base}.txt" | Out-File "${base}.m3u" -Append
Remove-Item "${base}.txt"
Write-Host "Playlist file created: ${base}.m3u"
Run with
.\yt-inna-pl.ps1 -url "https://www.youtube.com/playlist?list=XYZ" -basename "my_playlist"
▶️ How to Use It
Copy a YouTube playlist or mix URL.
Run the function:
yt-inna-pl "https://www.youtube.com/playlist?list=YOUR_PLAYLIST_ID" my_playlist
It will create a file like: ~/Downloads/my_playlist.m3u
Open this .m3u
in IINA, VLC, or MPV, and enjoy!
💡 Bonus Tips
Works with YouTube Mixes, Liked Videos, or any playlist URL.
You can customize the download path by editing the
base
variable.The M3U file can be imported into media library apps for long-term archiving.
🎉 Conclusion
With just a few lines of shell script and powerful open-source tools, you can turn YouTube into your own private playlist generator. Whether you use IINA on macOS or VLC elsewhere, this is a powerful, lightweight setup for music lovers and media nerds alike.