[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emms-patches] completion in lastfm
From: |
Thierry Volpiatto |
Subject: |
[Emms-patches] completion in lastfm |
Date: |
Thu, 07 Aug 2008 15:32:37 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
Hi emms,
here a little patch to have some completion in lastfm for global-tag
and similar-artist.
I didn't touch these functions, i just create new ones with an
independent timer to not interfer with the actual one.
This patch apply fine on revision:
,----
| commit 476e78d230e3f28dffb2b65482b9044970979167
| Commit: thierry <address@hidden>
| CommitDate: Thu Aug 7 14:56:41 2008 +0200
|
| emms-lastfm.el:Add completion for names of similar artists and music
type
|
|
| commit 3c8448d655e701d42ce6c0fcdd4a9438eb5d3b67
| Commit: Yoni Rabkin <address@hidden>
| CommitDate: Fri Aug 1 17:29:21 2008 +0300
|
| emms.texinfo: New advocacy section in the manual titled "Formats and
Freedom".
`----
## Merge of all patchs applied from revision 839
## Initial-patch
## patch2-841
## patch3-842
##
diff --git a/lisp/emms-lastfm.el b/lisp/emms-lastfm.el
--- a/lisp/emms-lastfm.el
+++ b/lisp/emms-lastfm.el
@@ -87,6 +87,7 @@
(require 'emms-playing-time)
(require 'emms-source-file)
(require 'emms-url)
+(eval-when-compile (require 'cl))
;;; Variables
@@ -648,6 +649,102 @@
(emms-track-set track 'info-title title)
(emms-track-updated track))))
+;;; New functions to get completion in similar-artist and global-tags
+;; launch last-fm with completion
+;; and launch also `emms-lastfm-radio-request-metadata'
+(defvar emms-lastfm-timer2 nil)
+(defcustom emms-default-music-directory
+ "~/music"
+ "The default directory to store music"
+ :type 'string
+ :group 'emms-player-lastfm-radio)
+
+(defcustom emms-music-type-list
+ '("playlist" "blues"
+ "trance" "classical"
+ "rock" "country"
+ "pop" "electronic"
+ "reggae" "hip-hop"
+ "indierock" "jazz"
+ "latin" "punk"
+ "RnB" "soul"
+ "world" "50s"
+ "60s" "70s"
+ "80s" "recommended"
+ "ethno")
+ "List of music type recognized by lastfm"
+ :type 'list
+ :group 'emms-player-lastfm-radio)
+
+(defvar emms-completing-read (if (and (boundp 'ido-mode)
+ ido-mode)
+ 'ido-completing-read
+ 'completing-read)
+ "Idea and code come from `dvc'.See the doc of `completing-read'
+for arguments of function `emms-completing-read'")
+
+(defun emms-completing-read (&rest args)
+ "Read a string in the minibuffer, with completion.
+Set `emms-completing-read' to determine which function to use.
+
+See `completing-read' for a description of ARGS."
+ (apply emms-completing-read args))
+
+(defun emms-lastfm-radio-music-type (tag)
+ (interactive (list (emms-completing-read "MusicType: "
+ emms-music-type-list)))
+ (emms-lastfm-radio (concat "lastfm://globaltags/" tag))
+ (when emms-lastfm-timer2
+ (emms-cancel-lastfm-infos))
+ (emms-update-lastfm-infos))
+
+;; Manage timer to display infos in mode-line
+(defun emms-update-lastfm-infos ()
+ (setq emms-lastfm-timer2 (run-with-timer "2"
+ emms-lastfm-radio-metadata-period
+ #'(lambda ()
+ (when
emms-player-playing-p
+
(emms-lastfm-radio-request-metadata))))))
+
+
+(defun emms-cancel-lastfm-infos ()
+ (cancel-timer emms-lastfm-timer2)
+ (setq emms-lastfm-timer2 nil))
+
+;; Get all artists in my music directory
+(defun emms-lastfm-list-music-directory (directory)
+ (let ((dir-list nil)
+ (mod-name))
+ (loop for i in (cddr (directory-files directory))
+ do
+ (setq mod-name (replace-regexp-in-string "_" " " i))
+ (push (split-string mod-name "\\-") dir-list))
+ (setq dir-list (reverse dir-list))
+ dir-list))
+
+(defun emms-lastfm-list-music-directory-by-artist (directory)
+ (let ((dir-list nil)
+ (dir-list-single nil))
+ (loop for i in (emms-lastfm-list-music-directory directory)
+ do
+ (push (car i) dir-list))
+ (dolist (x dir-list)
+ (when (not (member x dir-list-single))
+ (push x dir-list-single)))
+ dir-list-single))
+
+;; Start lastfm by similar artists using the artists
+;; presents in my music directory
+(defun emms-lastfm-radio-by-artist (artist)
+ (interactive (list (emms-completing-read "SimilarArtists: "
+
(emms-lastfm-list-music-directory-by-artist
+ emms-default-music-directory))))
+ (emms-lastfm-radio (concat "lastfm://artist/"
+ artist
+ "/similarartists"))
+ (when emms-lastfm-timer2
+ (emms-cancel-lastfm-infos))
+ (emms-update-lastfm-infos))
;;; Utility functions
--
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France
- [Emms-patches] completion in lastfm,
Thierry Volpiatto <=