diff options
author | Rasmus <rasmus@gmx.us> | 2015-03-15 17:31:30 +0100 |
---|---|---|
committer | Rasmus <rasmus@gmx.us> | 2015-03-17 02:58:17 +0100 |
commit | 6bc53c76eadaee1ba37d6301c28ac987d77c0124 (patch) | |
tree | 06207d809e4147f59fd7200ed949f37a998de64f /lisp | |
parent | 9e48ab1ab4cdeee69bfa8d327b54f85f6a54115f (diff) |
emms-lyrics: Use eww if present to display lyrics
Lyrics are now fetched from lyricwiki.org. It is possible to change the
url, but it assumes a certain order of the format string.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/emms-lyrics.el | 55 |
1 files changed, 35 insertions, 20 deletions
diff --git a/lisp/emms-lyrics.el b/lisp/emms-lyrics.el index a7c3176..6325ceb 100644 --- a/lisp/emms-lyrics.el +++ b/lisp/emms-lyrics.el @@ -128,6 +128,15 @@ Note: Even if this is set to t, it also depends on (defvar emms-lyrics-buffer nil "Buffer to show lyrics.") +(defvar emms-lyrics-chinese-url "http://mp3.baidu.com/m?f=ms&rn=10&tn=baidump3lyric&ct=150994944&word=%s&lm=-1" + "URL used to find Chinese lyrics. +Should contain one %s which is replaced with the filename.") + +(defvar emms-lyrics-latin-url "http://lyrics.wikia.com/%s%s" + "URL used to find Latin lyrics. +Should contain two %s-expressions. The first is replaced with +the artist and second with the title.") + ;;;###autoload (defun emms-lyrics-enable () "Enable displaying emms lyrics." @@ -216,26 +225,32 @@ If we can't find it from local disk, then search it from internet." (file-name-nondirectory name))))) (if (and lrc (file-exists-p lrc) (not (string= lrc ""))) (find-file lrc) - (message "lyric file does not exist, search for it online...") - (let ((title (emms-track-get track 'info-title)) - (filename (file-name-sans-extension - (file-name-nondirectory name))) - (url "")) - (unless title - (setq title filename)) - (cond ((string-match "\\cc" title) ; chinese lyrics - ;; Since tag info might be encoded using various coding - ;; systems, we'd better fall back on filename. - (setq url (format - "http://mp3.baidu.com/m?f=ms&rn=10&tn=baidump3lyric&ct=150994944&word=%s&lm=-1" - (emms-url-quote-plus - (encode-coding-string filename 'gb2312))))) - (t ; english lyrics - (setq url (format "http://search.lyrics.astraweb.com/?word=%s" - ;;"http://www.lyrics007.com/cgi-bin/s.cgi?q=" - (emms-url-quote-plus title))))) - (browse-url url) - (message "lyric file does not exist, search it from internet...done"))))) + (message "Lyric file does not exist on file-system. Searching online...") + (let* ((title (or (emms-track-get track 'info-title) + (file-name-sans-extension + (file-name-nondirectory name)))) + (artist (when (emms-track-get track 'info-title) + (emms-track-get track 'info-artist))) + (url + (cond ((string-match "\\cc" title) ; Chinese lyrics. + ;; Since tag info might be encoded using various coding + ;; systems, we'd better fall back on filename. + (format emms-lyrics-chinese-url + (emms-url-quote-plus + (encode-coding-string filename 'gb2312)))) + (t ; English lyrics. + (format emms-lyrics-latin-url + (if artist (concat (emms-url-quote-underscore artist) ":") "") + (emms-url-quote-underscore title)))))) + (if (fboundp 'eww) + (let ((readable-hook (when (and (fboundp 'eww-readable) + (not (memq 'eww-readable eww-after-render-hook))) + (add-hook 'eww-after-render-hook 'eww-readable)))) + (eww url) + (when readable-hook + (remove-hook 'eww-after-render-hook 'eww-readable))) + (browse-url url)) + (message "Lyric file does not exist on file-system. Searching online..."))))) ;;; EMMS Lyrics |