Fetch song lyrics and album covers. Integrates with EMMS
Find a file
2021-08-07 17:23:20 +03:00
img docs: README, typos in docstrings 2021-08-07 17:23:20 +03:00
.gitignore Initial commit 2021-08-05 18:33:37 +03:00
Cask feat: actual major mode for lyrics, Cask 2021-08-07 15:55:28 +03:00
LICENSE Initial commit 2021-08-05 18:33:37 +03:00
lyrics-fetcher-genius.el docs: README, typos in docstrings 2021-08-07 17:23:20 +03:00
lyrics-fetcher.el docs: README, typos in docstrings 2021-08-07 17:23:20 +03:00
README.org docs: README, typos in docstrings 2021-08-07 17:23:20 +03:00

lyrics-fetcher.el

A package to fetch song lyrics and album covers. Integrates with EMMS.

/sqrtminusone/lyrics-fetcher.el/media/tag/0.1.0/img/screenshot.png

As of now, the only available backend is genius.com, but in principle, new ones can be added.

Installation

As the package isn't yet available anywhere but in this repository, you can clone the repository, add it to the load-path and require the package:

(require 'lyrics-fetcher)

My preferred way is to use use-package with straight:

(use-package lyrics-fetcher
  :straight (:host github :repo "SqrtMinusOne/lyrics-fetcher.el")
  :after (emms))

Install imagemagick if you want to download covers.

Set genius.com client access token. To do that, create a new client, click "Generate Access Token" and put the result to the lyrics-fetcher-genius-access-token variable. I do this with password-store:

(setq lyrics-fetcher-genius-access-token
      (password-store-get "My_Online/APIs/genius.com"))

But of course, you can just hardcode the string.

Usage

Available commands:

  • M-x lyrics-fetcher-show-lyrics - show lyrics for the current playing track. The resulting lyric files are saved to the lyrics-fetcher-lyrics-folder and have the lyrics-fetcher-lyrics-file-extension extension. The folder will be created if it doesn't exist. By default, the function opens an already saved lyrics file if one exists, otherwise tries to fetch the lyrics. If called with C-u, then tries to fetch the text regardless of the latter. If called with C-u C-u, prompts the user to select a matching song. That is helpful when there are multiple songs with similar names, and the top one isn't the right one.
  • M-x lyrics-fetcher-show-lyrics-query - fetch lyrics by a text query. Modified by C-u the same way as lyrics-fetcher-show-lyrics.

EMMS integration:

  • M-x lyrics-fetcher-emms-browser-show-at-point - fetch data for the current point in EMMS browser. If the point contains just one song, it will be fetched the usual way and lyrics will be shown upon successful completion. If the point contains many songs (e.g. it's an album), the lyrics will be fetched consequentially for every song. The process then will stop at the first failure. Modified by C-u the same way as lyrics-fetcher-show-lyrics.
  • M-x lyrics-fetcher-emms-browser-fetch-covers-at-point - fetch album covers for the current point in the EMMS browser. This functionality requires songs' directories to be grouped by albums, i.e. one album per one folder. The files will be saved to the folder with names like "cover_small.jpg", "cover_med.jpg", "cover_large.jpg". You can customize the sizes via the lyrics-fetcher-small-cover-size and lyrics-fetcher-medium-cover-size variables. Modified by C-u the same way as lyrics-fetcher-show-lyrics.
  • M-x lyrics-fetcher-emms-browser-open-large-cover-at-point - open large_cover for the current point in EMMS browser.

Lyric view mode keybindings:

  • q - close the lyrics buffer
  • r - refetch the lyrics in the buffer

Customization and extension

Lyrics file naming and location

As was outlined above, lyrics files are saved to lyrics-fetcher-lyrics-folder and have an extension set in lyrics-fetcher-lyrics-file-extension.

Take a look at the lyrics-fetcher-format-song-name-method and lyrics-fetcher-format-file-name-method variables if you want to customize the lyrics buffer and file naming.

Using another player than EMMS

To use another player, customize lyrics-fetcher-current-track-method.

This variable contains a function that returns the current playing track. The return format has to be either a string or (recommended) an EMMS-like alist, which has to have the following fields:

  • info-artist or info-albumartist
  • info-title

Adding another backend

A function to perform the lyric fetching is set in lyrics-fetcher-fetch-method.

The function has to receive 3 arguments:

  • track - a string or alist, as outlined above.
  • callback - the function which has to be called with the resulting lyrics string
  • sync - if non-nil, inquire the user about the possible choices. This is called sync because then it is reasonable to perform the request synchronously, as otherwise, it won't be nice to suddenly throw a prompt at the user.

The album cover fetching is similar. The corresponding function is set in lyrics-fetcher-download-cover-method and has to receive the following parameters:

  • track - as above
  • callback - has to be called with the path to the resulting file. This file should be named cover_large.<extension>.
  • folder - where the file has to be put
  • sync - as above.

The first argument is track because in EMMS all the required information is stored in tracks, and album data is deduced from tracks. So this package just takes a sample track in the album.