Skip to content

shardulvs/ytmusic.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ytmusic.nvim

A simple Neovim plugin to play YouTube Music directly from your editor.

Requirements

  1. mpv: Must be in your $PATH.
  2. yt-dlp: CRITICAL - Must be the LATEST version.
    • YouTube frequently changes their backend. The version in apt or brew is often too old.

Installation

Using lazy.nvim

{
  "shardulvs/ytmusic.nvim",
}

Cookies (Fix for "Sign in" errors)

If you get errors like "Sign in to confirm you’re not a bot" or "403 Forbidden":

  1. Export your cookies from your browser (Netscape format).
    • Use a browser extension like "Get cookies.txt LOCALLY".
  2. Set the environment variable in your shell (.bashrc / .zshrc):
    export YOUTUBE_COOKIES_FILE="/path/to/your/cookies.txt"

Usage

  1. Create a file with .ytmusic extension (e.g., playlist.ytmusic).
  2. Paste YouTube Music URLs:
    https://music.youtube.com/watch?v=d9S4diaWjos
    
  3. Open the file in Neovim. Titles will be fetched automatically.
  4. Controls:
    • <Enter>: Play / Stop.
    • :YtStop: Emergency stop all playback.
    • :FetchTitles: Manually re-scan the file for new links and fetch their titles.
    • Closing Buffer: Stops playback immediately.

Importing Playlists

To easily get all links from a YouTube Music playlist:

  1. Open the playlist in your browser.
  2. Scroll down to load all songs.
  3. Open Developer Tools (F12) -> Console.
  4. Paste this snippet to copy all links:
console.log([...new Set(Array.from(document.querySelectorAll("ytmusic-responsive-list-item-renderer a[href*='watch?v=']")).map(a=>"https://music.youtube.com/watch?v="+a.href.split("v=")[1].split("&")[0]))].join("\n"))

Disclaimer

If this plugin breaks in the future, feel free to blame YouTube. They love changing their backend APIs just to mess with us. If that happens, update yt-dlp and pray.

License

MIT

About

play music right from your editor

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages