mirror of
https://github.com/SqrtMinusOne/lyrics-fetcher.el.git
synced 2025-12-10 17:03:03 +03:00
fix: pass C-u while fetching cover, strip parens in Genius query
This commit is contained in:
parent
5a752a2cab
commit
2d68bd4806
2 changed files with 28 additions and 7 deletions
|
|
@ -31,6 +31,7 @@
|
|||
(require 'request)
|
||||
(require 'cl-lib)
|
||||
(require 'json)
|
||||
(require 'subr)
|
||||
(require 'seq)
|
||||
(require 'shr)
|
||||
(require 'f)
|
||||
|
|
@ -40,6 +41,14 @@
|
|||
:type '(string nil)
|
||||
:group 'lyrics-fetcher)
|
||||
|
||||
(defcustom lyrics-fetcher-genius-strip-parens-from-query t
|
||||
"Strip parens from the query.
|
||||
|
||||
I've noticed that these often break the search, e.g. when
|
||||
searching \"Song (feat. Artist)\""
|
||||
:type 'boolean
|
||||
:group 'lyrics-fetcher)
|
||||
|
||||
(defun lyrics-fetcher-genius-do-search (track callback &optional sync)
|
||||
"Perform a lyrics search on 'genius.com'.
|
||||
|
||||
|
|
@ -96,16 +105,26 @@ after the request."
|
|||
(defun lyrics-fetcher--genius-format-query (track)
|
||||
"Format track to genius.com query.
|
||||
|
||||
When `lyrics-fetcher-genius-strip-parens-from-query' is non-nil,
|
||||
remove all the text in parens from the query,
|
||||
for instance (feat. someone).
|
||||
|
||||
TRACK should either be a string or an EMMS-compatible alist, which
|
||||
contains `info-albumartist' or `info-artist' and `info-title'"
|
||||
(if (stringp track)
|
||||
track
|
||||
(concat
|
||||
(let ((query (concat
|
||||
(or (cdr (assoc 'info-albumartist track))
|
||||
(cdr (assoc 'info-artist track))
|
||||
"")
|
||||
" "
|
||||
(cdr (assoc 'info-title track)))))
|
||||
(when lyrics-fetcher-genius-strip-parens-from-query
|
||||
(setq query (replace-regexp-in-string
|
||||
(rx (or (: "(" (* nonl) ")")
|
||||
(: "[" (* nonl) "]")))
|
||||
"" query)))
|
||||
query)))
|
||||
|
||||
(defun lyrics-fetcher--genius-format-song-title (entry)
|
||||
"Convert a Genius search ENTRY to a string, which can be used in selection."
|
||||
|
|
|
|||
|
|
@ -439,7 +439,9 @@ FORCE-FETCH and SYNC are passed to `lyrics-fetcher--fetch-cover'."
|
|||
(cdr tracks)
|
||||
:start (+ start 1)
|
||||
:force-fetch force-fetch
|
||||
:sync sync))))))
|
||||
:sync sync))
|
||||
:sync sync
|
||||
:force-fetch force-fetch))))
|
||||
|
||||
(cl-defun lyrics-fetcher--fetch-cover (track &optional &key callback sync force-fetch)
|
||||
"Fetch cover for a given TRACK.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue