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 'request)
|
||||||
(require 'cl-lib)
|
(require 'cl-lib)
|
||||||
(require 'json)
|
(require 'json)
|
||||||
|
(require 'subr)
|
||||||
(require 'seq)
|
(require 'seq)
|
||||||
(require 'shr)
|
(require 'shr)
|
||||||
(require 'f)
|
(require 'f)
|
||||||
|
|
@ -40,6 +41,14 @@
|
||||||
:type '(string nil)
|
:type '(string nil)
|
||||||
:group 'lyrics-fetcher)
|
: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)
|
(defun lyrics-fetcher-genius-do-search (track callback &optional sync)
|
||||||
"Perform a lyrics search on 'genius.com'.
|
"Perform a lyrics search on 'genius.com'.
|
||||||
|
|
||||||
|
|
@ -96,16 +105,26 @@ after the request."
|
||||||
(defun lyrics-fetcher--genius-format-query (track)
|
(defun lyrics-fetcher--genius-format-query (track)
|
||||||
"Format track to genius.com query.
|
"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
|
TRACK should either be a string or an EMMS-compatible alist, which
|
||||||
contains `info-albumartist' or `info-artist' and `info-title'"
|
contains `info-albumartist' or `info-artist' and `info-title'"
|
||||||
(if (stringp track)
|
(if (stringp track)
|
||||||
track
|
track
|
||||||
(concat
|
(let ((query (concat
|
||||||
(or (cdr (assoc 'info-albumartist track))
|
(or (cdr (assoc 'info-albumartist track))
|
||||||
(cdr (assoc 'info-artist track))
|
(cdr (assoc 'info-artist track))
|
||||||
"")
|
"")
|
||||||
" "
|
" "
|
||||||
(cdr (assoc 'info-title 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)
|
(defun lyrics-fetcher--genius-format-song-title (entry)
|
||||||
"Convert a Genius search ENTRY to a string, which can be used in selection."
|
"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)
|
(cdr tracks)
|
||||||
:start (+ start 1)
|
:start (+ start 1)
|
||||||
:force-fetch force-fetch
|
: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)
|
(cl-defun lyrics-fetcher--fetch-cover (track &optional &key callback sync force-fetch)
|
||||||
"Fetch cover for a given TRACK.
|
"Fetch cover for a given TRACK.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue