mirror of
https://github.com/SqrtMinusOne/lyrics-fetcher.el.git
synced 2025-12-10 08:53:04 +03:00
refator: fix package-lint errors
This commit is contained in:
parent
cbbf6244af
commit
46a2045526
1 changed files with 24 additions and 24 deletions
|
|
@ -1,4 +1,4 @@
|
|||
;;; lyrics-fetcher-genius.el --- fetch lyrics from genius.com -*- lexical-binding: t -*-
|
||||
;;; lyrics-fetcher-genius.el --- Fetch lyrics from genius.com -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2021 Korytov Pavel
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ The flow is as follows:
|
|||
4. Call CALLBACK with the resulting lyrics string
|
||||
|
||||
TRACK should be EMMS-compatible alist or string, take a look at
|
||||
`lyrics-fetcher--genius-format-query'. If the search is
|
||||
`lyrics-fetcher-genius--format-query'. If the search is
|
||||
successful, CALLBACK will be called with the result.
|
||||
|
||||
If SYNC is non-nil, perform request synchronously and ask the
|
||||
|
|
@ -70,23 +70,23 @@ user to pick the matching search result.
|
|||
When EDIT is non-nil, edit the query in minibuffer before search.
|
||||
Genius usually struggles to find song if there is extra
|
||||
information in the title."
|
||||
(lyrics-fetcher--genius-do-query
|
||||
(lyrics-fetcher-genius--do-query
|
||||
track
|
||||
(lambda (data)
|
||||
(lyrics-fetcher--genius-fetch-lyrics
|
||||
(lyrics-fetcher--genius-get-data-from-response data 'url sync)
|
||||
(lyrics-fetcher-genius--fetch-lyrics
|
||||
(lyrics-fetcher-genius--get-data-from-response data 'url sync)
|
||||
callback
|
||||
sync))
|
||||
sync
|
||||
edit))
|
||||
|
||||
(defun lyrics-fetcher--genius-do-query (track callback &optional sync edit)
|
||||
(defun lyrics-fetcher-genius--do-query (track callback &optional sync edit)
|
||||
"Perform a song search on genius.com.
|
||||
|
||||
Requires `lyrics-fetcher-genius-access-token' to be set.
|
||||
|
||||
TRACK should be EMMS-compatible alist or string, take a look at
|
||||
`lyrics-fetcher--genius-format-query'. If the search is
|
||||
`lyrics-fetcher-genius--format-query'. If the search is
|
||||
successful, CALLBACK will be called with the result.
|
||||
|
||||
SYNC determines whether the request is synchronous. The parameter
|
||||
|
|
@ -98,8 +98,8 @@ When EDIT is non-nil, edit the query in minibuffer before search."
|
|||
(error "Genius client access token not set!"))
|
||||
(message "Sending a query to genius API...")
|
||||
(request "https://api.genius.com/search"
|
||||
:params `(("q" . ,(lyrics-fetcher--genius-maybe-edit-query
|
||||
(lyrics-fetcher--genius-format-query track)
|
||||
:params `(("q" . ,(lyrics-fetcher-genius--maybe-edit-query
|
||||
(lyrics-fetcher-genius--format-query track)
|
||||
edit))
|
||||
("access_token" . ,lyrics-fetcher-genius-access-token))
|
||||
:parser 'json-read
|
||||
|
|
@ -111,13 +111,13 @@ When EDIT is non-nil, edit the query in minibuffer before search."
|
|||
(lambda (&key error-thrown &allow-other-keys)
|
||||
(message "Error!: %S" error-thrown)))))
|
||||
|
||||
(defun lyrics-fetcher--genius-maybe-edit-query (query edit)
|
||||
"If EDIT is non-nil, edit QUERY if minibuffer."
|
||||
(defun lyrics-fetcher-genius--maybe-edit-query (query edit)
|
||||
"If EDIT is non-nil, edit QUERY in minibuffer."
|
||||
(when edit
|
||||
(read-from-minibuffer "Query: " query))
|
||||
query)
|
||||
|
||||
(defun lyrics-fetcher--genius-format-query (track)
|
||||
(defun lyrics-fetcher-genius--format-query (track)
|
||||
"Format track to genius.com query.
|
||||
|
||||
When `lyrics-fetcher-genius-strip-parens-from-query' is non-nil,
|
||||
|
|
@ -141,14 +141,14 @@ contains `info-albumartist' or `info-artist' and `info-title'"
|
|||
"" 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."
|
||||
(let ((result (assoc 'result entry)))
|
||||
(format "%-40s [lyrics: %s]"
|
||||
(cdr (assoc 'full_title result))
|
||||
(cdr (assoc 'lyrics_state result)))))
|
||||
|
||||
(defun lyrics-fetcher--genius-get-data-from-response (data key &optional ask)
|
||||
(defun lyrics-fetcher-genius--get-data-from-response (data key &optional ask)
|
||||
"Retrieve a song KEY from the Genius response DATA.
|
||||
|
||||
If ASK is non-nil, prompt the user for a choice, otherwise select the
|
||||
|
|
@ -167,7 +167,7 @@ first song."
|
|||
(let ((results-songs-for-select
|
||||
(mapcar
|
||||
(lambda (entry)
|
||||
(cons (lyrics-fetcher--genius-format-song-title entry)
|
||||
(cons (lyrics-fetcher-genius--format-song-title entry)
|
||||
(assoc key (assoc 'result entry))))
|
||||
results-songs)))
|
||||
(cdr
|
||||
|
|
@ -179,7 +179,7 @@ first song."
|
|||
results-songs-for-select)))
|
||||
(assoc key (assoc 'result (car results-songs)))))))
|
||||
|
||||
(defun lyrics-fetcher--genius-fetch-lyrics (url callback &optional sync)
|
||||
(defun lyrics-fetcher-genius--fetch-lyrics (url callback &optional sync)
|
||||
"Fetch lyrics from genius.com page at URL and call CALLBACK with the result.
|
||||
|
||||
If SYNC is non-nil, the request will be performed synchronously."
|
||||
|
|
@ -212,7 +212,7 @@ Requires `lyrics-fetcher-genius-access-token' to be set and
|
|||
imagemagick's \"convert\" to be available in PATH.
|
||||
|
||||
TRACK should be EMMS-compatible alist or string, take a look at
|
||||
`lyrics-fetcher--genius-format-query'. If the search is successful,
|
||||
`lyrics-fetcher-genius--format-query'. If the search is successful,
|
||||
CALLBACK will be called with the resulting filename of the large
|
||||
cover.
|
||||
|
||||
|
|
@ -227,35 +227,35 @@ CALLBACK will be called with a path to the resulting file.
|
|||
If SYNC is non-nil, the user will be prompted for a matching song.
|
||||
|
||||
When EDIT is non-nil, edit the query in minibuffer before search."
|
||||
(lyrics-fetcher--genius-do-query
|
||||
(lyrics-fetcher-genius--do-query
|
||||
track
|
||||
(lambda (data)
|
||||
(lyrics-fetcher--genius-save-album-picture
|
||||
(lyrics-fetcher--genius-get-data-from-response data 'id sync)
|
||||
(lyrics-fetcher-genius--save-album-picture
|
||||
(lyrics-fetcher-genius--get-data-from-response data 'id sync)
|
||||
callback
|
||||
folder))
|
||||
sync
|
||||
edit))
|
||||
|
||||
(defun lyrics-fetcher--genius-save-album-picture (id callback folder)
|
||||
(defun lyrics-fetcher-genius--save-album-picture (id callback folder)
|
||||
"Save an album cover of a song of a given ID.
|
||||
|
||||
The file will be saved to FOLDER and will be named
|
||||
\"cover_large.<extension>\".
|
||||
|
||||
CALLBACK is passed to `lyrics-fetcher--genius-save-album-url'."
|
||||
CALLBACK is passed to `lyrics-fetcher-genius--save-album-url'."
|
||||
(request
|
||||
(format "https://api.genius.com/songs/%s" id)
|
||||
:parser 'json-read
|
||||
:params `(("access_token" . ,lyrics-fetcher-genius-access-token))
|
||||
:success (cl-function
|
||||
(lambda (&key data &allow-other-keys)
|
||||
(lyrics-fetcher--genius-save-album-url data callback folder)))
|
||||
(lyrics-fetcher-genius--save-album-url data callback folder)))
|
||||
:error (cl-function
|
||||
(lambda (&key error-thrown &allow-other-keys)
|
||||
(message "Error!: %S" error-thrown)))))
|
||||
|
||||
(defun lyrics-fetcher--genius-save-album-url (data callback folder)
|
||||
(defun lyrics-fetcher-genius--save-album-url (data callback folder)
|
||||
"Save album cover of DATA to FOLDER.
|
||||
|
||||
DATA should be a response from GET /songs/:id. The file will be saved
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue