Skip to content
A Common Lisp library for playing youtube videos
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md Handle "video unavailable" cases for valid youtube links Jun 13, 2019
package.lisp Use bt Jun 21, 2019
youtube.asd Use bt Jun 21, 2019
youtube.lisp Update error handling for unavailable videos Jun 21, 2019

README.md

youtube

Play songs from youtube given a youtube url or a search string. Uses youtube-dl and the mpv player.

Installation

Make sure you have mpv and youtube-dl installed.

# clone to local-projects for quickload access
git clone https://github.com/mihaiolteanu/youtube ~/quicklisp/local-projects/youtube
; Register the new project
(ql:register-local-projects)

Usage

(ql:quickload :youtube)

Play a known url

(play "https://www.youtube.com/watch?v=skpQ-joyuLw")

Or let youtube-dl search for a youtube url given an artist name and a song name and play that

(play "anathema one last goodbye")

This will start an mpv player instance listening on the /tmp/mpv-cl-socket socket. By default, mpv runs with no video support, in the background.

Following this, you can control the playback by pausing the player, rewinding, opening a youtube page or querying the playback position. See the API for details.

API

play url-or-song &key (video nil) (pos "0")

Play the youtube url through mpv. If `video` is T, open the video with mpv
player, if not, run mpv in the background. If position is specified, in seconds,
start playback from there. If the youtube link is valid but the video is
unavailable for some reason, return nil and don't play anything.

play/pause

Toggle playing status.

replay

Rewind the song at the beginning, effectively replaying it.

seek seconds

Forward or backward play by seconds, if the seconds is negative.

percent-pos

Current playing song position, in percent.

time-pos

Current playing song position, in seconds, as string.

duration

Current playing song duration, in MM:SS format, as string.

switch-to-browser &key (from-beginning nil)

Pause the player and open the youtube page of the current playing song in the
user default browser. If `from-beginning` is T, start playing from the beginning,
otherwise continue from where the player was. 

turn-video-on

Quit mpv and restart it in video mode, locally (i.e. not in the browser)

quit

Stop the playback.

Authors

Copyright (c) 2019 Mihai Olteanu

Licensed under the GPLv3 license.

You can’t perform that action at this time.