;ELC ;;; Compiled by heimdall@localhost on Sat Feb 16 17:23:48 2008 ;;; from file /home/heimdall/repos/emms/emms-lastfm.el ;;; in Emacs version 23.0.60.1 ;;; with all optimizations. ;;; This file uses dynamic docstrings, first added in Emacs 19.29. (if (and (boundp 'emacs-version) (< (aref emacs-version (1- (length emacs-version))) ?A) (or (and (boundp 'epoch::version) epoch::version) (string-lessp emacs-version "19.29"))) (error "`emms-lastfm.el' was compiled for Emacs 19.29 or later")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (byte-code "\300\301!\210\300\302!\210\300\303!\210\300\304!\210\300\305!\210\300\306!\210\307\310\311\312\313\314\315\302&\207" [require url emms emms-mode-line emms-playing-time emms-source-file emms-url custom-declare-group emms-lastfm nil "Interaction with the services offered by http://www.last.fm." :prefix "emms-lastfm-" :group] 8) #@23 Your last.fm username (custom-declare-variable 'emms-lastfm-username '"" '(#$ . 929) :type 'string :group 'emms-lastfm) #@23 Your last.fm password (custom-declare-variable 'emms-lastfm-password '"" '(#$ . 1055) :type 'string :group 'emms-lastfm) #@72 If non-nil, display a message every time we submit a track to Last.fm. (custom-declare-variable 'emms-lastfm-submission-verbose-p 'nil '(#$ . 1182) :type 'boolean :group 'emms-lastfm) #@241 Specify what types of tracks to submit to Last.fm. The default is to only submit files. To submit every track to Last.fm, set this to t. Note that it is not very meaningful to submit playlists, streamlists, or Last.fm streams to Last.fm. (custom-declare-variable 'emms-lastfm-submit-track-types ''(file) '(#$ . 1373) :type '(choice (const :tag "All" t) (set :tag "Types" (const :tag "Files" file) (const :tag "URLs" url) (const :tag "Playlists" playlist) (const :tag "Streamlists" streamlist) (const :tag "Last.fm streams" lastfm))) :group 'emms-lastfm) #@86 The last.fm server responsible for the handshaking procedure. Only for internal use. (defconst emms-lastfm-server "http://post.audioscrobbler.com/" (#$ . 1935)) #@41 The client ID of EMMS. Don't change it! (defconst emms-lastfm-client-id "ems" (#$ . 2102)) #@53 The version registered at last.fm. Don't change it! (defconst emms-lastfm-client-version 0.2 (#$ . 2199)) #@28 -- only used internally -- (defvar emms-lastfm-process nil (#$ . 2311)) #@28 -- only used internally -- (defvar emms-lastfm-session-id nil (#$ . 2389)) #@28 -- only used internally -- (defvar emms-lastfm-now-playing-url nil (#$ . 2470)) #@28 -- only used internally -- (defvar emms-lastfm-submit-url nil (#$ . 2556)) #@28 -- only used internally -- (defvar emms-lastfm-current-track nil (#$ . 2637)) #@28 -- only used internally -- (defvar emms-lastfm-timer nil (#$ . 2721)) #@28 -- only used internally -- (defvar emms-lastfm-current-track-starting-time-string nil (#$ . 2797)) #@119 This function should run whenever a new track starts (or a paused track resumes) and sets the track submission timer. (defalias 'emms-lastfm-new-track-function #[nil "\306 \307 \310\311\"\312!\211\203E\f\313=\204$\f<\203E\n\f>\203E \314V\203,\314 \315W\204E \316\245 Z\211\317W\204E\320 \321\322#*\323 \207" [emms-lastfm-current-track emms-lastfm-current-track-starting-time-string type secs emms-lastfm-submit-track-types emms-playing-time emms-playlist-current-selected-track emms-lastfm-current-unix-time-string emms-track-get info-playing-time emms-track-type t 240 30 2 0 run-with-timer nil emms-lastfm-submit-track emms-lastfm-submit-now-playing emms-lastfm-timer] 5 (#$ . 2903)]) #@148 Perform a HTTP POST request to URL using STRING as data. STRING will be encoded to utf8 before the request. Call SENTINEL with the result buffer. (defalias 'emms-lastfm-http-POST #[(url string sentinel &optional sentinel-args) "\306\307\310\311 \312\"\f\313 #-\207" [emms-lastfm-submission-verbose-p string url-request-data url-request-extra-headers url-request-method url-show-status nil "POST" (("Content-type" . "application/x-www-form-urlencoded; charset=utf-8")) encode-coding-string utf-8 url-retrieve url-http-attempt-keepalives url sentinel sentinel-args] 7 (#$ . 3614)]) #@92 Perform a HTTP GET request to URL. Call SENTINEL with SENTINEL-ARGS and the result buffer. (defalias 'emms-lastfm-http-GET #[(url sentinel &optional sentinel-args) "\306\307 \f #*\207" [emms-lastfm-submission-verbose-p url-request-method url-show-status url sentinel sentinel-args "GET" url-retrieve] 4 (#$ . 4212)]) #@90 Submit now-playing infos to last.fm. These will be displayed on the user's last.fm page. (defalias 'emms-lastfm-submit-now-playing #[nil "\306\307\"\306\310\"\306\311\"\306\312\"\313\314\306\315\"\206\316!\317\316W\203G\203: \204>\320\321!\210T\211\202**\205o \205o\322 \323\324\325 !\326\325\n!\327\325 !\330\331\f\332 \260\333#.\207" [emms-lastfm-current-track artist title album track-number musicbrainz-id emms-track-get info-artist info-title info-album info-tracknumber "" number-to-string info-playing-time 0 5 sit-for 1 emms-lastfm-http-POST "&s=" "&a[0]=" emms-url-quote "&t[0]=" "&b[0]=" "&l[0]=" "&n[0]=" "&m[0]=" emms-lastfm-submit-now-playing-sentinel track-length i --dotimes-limit-- emms-lastfm-session-id emms-lastfm-now-playing-url] 17 (#$ . 4538)]) #@90 Parses the server reponse and inform the user if all worked well or if an error occured. (defalias 'emms-lastfm-submit-now-playing-sentinel #[(&rest args) "p\302!\210eb\210\303\304\305\306#\210\305y\210\303\307\305\306#\203( \203\"\310\311!\210\312!\202-\310\313\314 \")\207" [buffer emms-lastfm-submission-verbose-p emms-http-decode-buffer re-search-forward "^$" nil t "^OK$" message "EMMS: Now playing infos submitted to last.fm" kill-buffer "EMMS: Now playing infos couldn't be submitted to last.fm: %s" emms-read-line] 4 (#$ . 5356)]) #@47 Cancels `emms-lastfm-timer' if it is running. (defalias 'emms-lastfm-cancel-timer #[nil "\301!\210\302\211\207" [emms-lastfm-timer emms-cancel-timer nil] 2 (#$ . 5907)]) #@65 Handles things to be done when the player is paused or resumed. (defalias 'emms-lastfm-pause #[nil "\203\301 \207\302 \207" [emms-player-paused-p emms-lastfm-cancel-timer emms-lastfm-new-track-function] 1 (#$ . 6085)]) #@197 Start submitting the tracks you listened to to http://www.last.fm, if ARG is positive. If ARG is negative or zero submission of the tracks will be stopped. This applies to the current track, too. (defalias 'emms-lastfm #[(&optional ARG) "\203 \204 \306\307\310\"\207\n\204\306\307\311\"\207 \203: \312V\203:\313\314\315\316#\210\313\314\317\316#\210\313\320\321\"\210\313\322\323\"\210\306\324!\207\325\314\315\"\210\325\314\317\"\210\325\320\321\"\210\325\322\323\"\210\f\203V\326\f!\210\327\211\327\211\306\330!\207" [emms-lastfm-username emms-lastfm-password emms-playing-time-p ARG emms-lastfm-timer emms-lastfm-session-id message "%s" "EMMS: In order to activate the last.fm plugin you first have to set both `emms-lastfm-username' and `emms-lastfm-password'" "EMMS: The last.fm plugin needs the functionality provided by `emms-playing-time'. It seems that you disabled it explicitly in your init file using code like this: `(emms-playing-time -1)'. Delete that line and have a look at `emms-playing-time's doc string" 0 add-hook emms-player-started-hook emms-lastfm-handshake-if-needed t emms-lastfm-new-track-function emms-player-stopped-hook emms-lastfm-cancel-timer emms-player-paused-hook emms-lastfm-pause "EMMS Last.fm plugin activated" remove-hook emms-cancel-timer nil "EMMS Last.fm plugin deactivated" emms-lastfm-submit-url emms-lastfm-process emms-lastfm-current-track] 5 (#$ . 6314) "p"]) (byte-code "\300\301\302\"\210\303\301\302\304#\207" [defalias emms-lastfm-activate emms-lastfm emms-make-obsolete "EMMS 2.2"] 4) #@33 Enable the emms last.fm plugin. (defalias 'emms-lastfm-enable #[nil "\300\301!\207" [emms-lastfm 1] 2 (#$ . 7873) nil]) #@34 Disable the emms last.fm plugin. (defalias 'emms-lastfm-disable #[nil "\300\301!\207" [emms-lastfm -1] 2 (#$ . 7999) nil]) #@75 Disable and reenable the last.fm plugin. This will cause a new handshake. (defalias 'emms-lastfm-restart #[nil "\300 \210\301 \207" [emms-lastfm-disable emms-lastfm-enable] 1 (#$ . 8128)]) (defalias 'emms-lastfm-handshake-if-needed #[nil "\205 \205 \n?\205\303 \207" [emms-lastfm-session-id emms-lastfm-submit-url emms-lastfm-now-playing-url emms-lastfm-handshake] 1]) (defalias 'emms-lastfm-current-unix-time-string #[nil "\300\301\302\303\304 !#\207" [replace-regexp-in-string "\\..*" "" number-to-string float-time] 5]) #@37 Handshakes with the last.fm server. (defalias 'emms-lastfm-handshake #[nil "\306 \307 \310\311\n\312\313 !\314\315\f!\316\317\320\211 !P!\260\f\321\")\207" [timestamp emms-lastfm-server emms-lastfm-client-id emms-lastfm-client-version emms-lastfm-username emms-lastfm-password emms-lastfm-current-unix-time-string emms-lastfm-http-GET "?hs=true&p=1.2" "&c=" "&v=" number-to-string "&u=" emms-url-quote "&t=" "&a=" md5 emms-lastfm-handshake-sentinel] 15 (#$ . 8663)]) #@90 Parses the server reponse and inform the user if all worked well or if an error occured. (defalias 'emms-lastfm-handshake-sentinel #[(&rest args) "p\305!\210eb\210\306\307\310\311#\210\310y\210\312 \313\314 \"\204#\315\316 \"\202<\310y\210\312 \310y\210\312 \310y\210\312 \315\317!\210\320!*\207" [buffer response emms-lastfm-session-id emms-lastfm-now-playing-url emms-lastfm-submit-url emms-http-decode-buffer re-search-forward "^$" nil t emms-read-line string-match "\\(?:OK\\)" message "EMMS: Handshake failed: %s" "EMMS: Handshaking with server done" kill-buffer] 4 (#$ . 9139)]) #@69 Submits the current track (`emms-lastfm-current-track') to last.fm. (defalias 'emms-lastfm-submit-track #[nil "\306\307\"\306\310\"\306\311\"\306\312\"\313\314\306\315\"!\316\317\320\321 !\322\321\n!\323\324\325\326\327\321 !\330\f\331 \260\332#.\207" [emms-lastfm-current-track artist title album track-number musicbrainz-id emms-track-get info-artist info-title info-album info-tracknumber "" number-to-string info-playing-time emms-lastfm-http-POST "&s=" "&a[0]=" emms-url-quote "&t[0]=" "&i[0]=" "&o[0]=P" "&r[0]=" "&l[0]=" "&b[0]=" "&n[0]=" "&m[0]=" emms-lastfm-submission-sentinel track-length emms-lastfm-submit-url emms-lastfm-session-id emms-lastfm-current-track-starting-time-string] 20 (#$ . 9739)]) #@90 Parses the server reponse and inform the user if all worked well or if an error occured. (defalias 'emms-lastfm-submission-sentinel #[(&rest args) "p\303!\210eb\210\304\305\306\307#\210\306y\210\304\310\306\307#\203+ \203%\311\312\313\n!\"\210\314!\2020\311\315\316 \")\207" [buffer emms-lastfm-submission-verbose-p emms-lastfm-current-track emms-http-decode-buffer re-search-forward "^$" nil t "^OK$" message "EMMS: \"%s\" submitted to last.fm" emms-track-description kill-buffer "EMMS: Song couldn't be submitted to last.fm: %s" emms-read-line] 4 (#$ . 10478)]) (custom-declare-group 'emms-player-lastfm-radio nil "EMMS player for Last.fm streams." :group 'emms-player :prefix "emms-player-lastfm-") #@43 *Parameters for the Last.fm radio player. (custom-declare-variable 'emms-player-lastfm-radio '(emms-player 'emms-lastfm-radio-start 'ignore 'emms-lastfm-radio-playable-p) '(#$ . -11192) :type '(cons symbol alist) :group 'emms-player-lastfm-radio) #@71 The base URL for playing lastfm:// stream. -- only used internally -- (defconst emms-lastfm-radio-base-url "http://ws.audioscrobbler.com/radio/" (#$ . 11445)) #@28 -- only used internally -- (defvar emms-lastfm-radio-session nil (#$ . 11610)) #@28 -- only used internally -- (defvar emms-lastfm-radio-stream-url nil (#$ . 11695)) (defalias 'emms-lastfm-radio-get-handshake-url #[nil "\305\306 !\307\n\310\311 !\312\313\f!\314\306\315!\260 \207" [emms-lastfm-radio-base-url emms-lastfm-client-version emms-lastfm-client-id emms-lastfm-username emms-lastfm-password "handshake.php?version=" number-to-string "&platform=" "&username=" emms-url-quote "&passwordmd5=" md5 "&debug=" 9] 12]) #@93 Handshakes with the last.fm server. Calls FN when done with RADIO-URL as its only argument. (defalias 'emms-lastfm-radio-handshake #[(fn radio-url) "\302\303 \304 D#\207" [fn radio-url emms-lastfm-http-GET emms-lastfm-radio-get-handshake-url emms-lastfm-radio-handshake-sentinel] 5 (#$ . 12139)]) (defalias 'emms-lastfm-radio-handshake-sentinel #[(status fn radio-url) "p\305!\210\306\307!\306\310!\311!\210 \203$\n\203$\312\313!\210 \f!\202'\312\314!)\207" [buffer emms-lastfm-radio-session emms-lastfm-radio-stream-url fn radio-url emms-http-decode-buffer emms-key-value "session" "stream_url" kill-buffer message "EMMS: Handshaking for Last.fm playback successful" "EMMS: Failed handshaking for Last.fm playback"] 2]) #@48 Internal function used by `emms-lastfm-radio'. (defalias 'emms-lastfm-radio-1 #[(lastfm-url) "\203 \203\304\n\305\306\307\310 !\311\312\313!\260\314\"\207\315\316!\207" [emms-lastfm-radio-session emms-lastfm-radio-stream-url emms-lastfm-radio-base-url lastfm-url emms-lastfm-http-GET "adjust.php?" "session=" "&url=" emms-url-quote "&debug=" number-to-string 0 emms-lastfm-radio-sentinel message "EMMS: Cannot play Last.fm stream"] 10 (#$ . 12875)]) #@188 Plays the stream associated with the given Last.fm URL. (A Last.fm URL has the form lastfm://foo/bar/baz, e.g. lastfm://artist/Manowar/similarartists or lastfm://globaltags/metal. (defalias 'emms-lastfm-radio #[(lastfm-url) "\303 \210\203 \204\304\305\n\"\207\305\n!\207" [emms-lastfm-radio-session emms-lastfm-radio-stream-url lastfm-url emms-lastfm-disable emms-lastfm-radio-handshake emms-lastfm-radio-1] 3 (#$ . 13339) "sLast.fm URL: "]) #@59 Determine whether the Last.fm player can play this track. (defalias 'emms-lastfm-radio-playable-p #[(track) "\303\302\"\303\301\" \304=\205\305\306\n\"*\207" [track type name emms-track-get lastfm string-match "^lastfm://"] 4 (#$ . 13799)]) #@22 Start playing TRACK. (defalias 'emms-lastfm-radio-start #[(track) "\302!\205\303\301\"\304 !)\207" [track name emms-lastfm-radio-playable-p emms-track-get emms-lastfm-radio] 3 (#$ . 14052)]) #@394 When listening to Last.fm Radio every how many seconds should emms-lastfm poll for metadata? If set to nil, there won't be any polling at all. The default is 15: That means that the mode line will display the wrong (last) track's data for a maximum of 15 seconds. If your network connection has a big latency this value may be too high. (But then streaming a 128KHz mp3 won't be fun anyway.) (custom-declare-variable 'emms-lastfm-radio-metadata-period '15 '(#$ . 14255) :type '(choice integer (const :tag "Disable" nil)) :group 'emms-lastfm) (defalias 'emms-lastfm-radio-sentinel #[(&rest args) "p\304!\210\305\306\"\307\230\203,\310!\210\311 !\210\n\203&\312\313\n\314#\315\316\317\"\210\320\321!\2023\310!\210\320\322!)\207" [buffer emms-lastfm-radio-stream-url emms-lastfm-radio-metadata-period emms-lastfm-timer emms-http-decode-buffer emms-key-value "response" "OK" kill-buffer emms-play-url run-with-timer 0 emms-lastfm-radio-request-metadata add-hook emms-player-stopped-hook emms-lastfm-cancel-timer message "EMMS: Playing Last.fm stream" "EMMS: Bad response from Last.fm"] 4]) #@271 Show the currently-playing lastfm radio tune. If INSERTP is non-nil, insert the description into the current buffer instead. If CALLBACK is a function, call it with the current buffer and description as arguments instead of displaying the description or inserting it. (defalias 'emms-lastfm-np #[(&optional insertp callback) "\302\303p E\"\207" [insertp callback emms-lastfm-radio-request-metadata #[(status insertp buffer callback) "p\306\211\307\n!\210\310\311\n\"\310\312\n\"\313\n!\210\203+ \203+\314 \314\315 #\"\202,\316\317 !\203C\205^ \205^ \f\"\202^\203[\203[ \203[rq\210\fc)\202^\320\f!,\207" [title artist response-buf emms-show-format msg callback nil emms-http-decode-buffer emms-key-value "artist" "track" kill-buffer format "%s - %s" "Nothing playing right now" functionp message buffer insertp] 6]] 5 (#$ . 15358) "P"]) #@43 Plays the similar artist radio of ARTIST. (defalias 'emms-lastfm-radio-similar-artists #[(artist) "\301\302\303Q!\207" [artist emms-lastfm-radio "lastfm://artist/" "/similarartists"] 4 (#$ . 16230) "sArtist: "]) #@36 Plays the global tag radio of TAG. (defalias 'emms-lastfm-radio-global-tag #[(tag) "\301\302P!\207" [tag emms-lastfm-radio "lastfm://globaltags/"] 3 (#$ . 16449) "sGlobal Tag: "]) #@39 Plays the artist fan radio of ARTIST. (defalias 'emms-lastfm-radio-artist-fan #[(artist) "\301\302\303Q!\207" [artist emms-lastfm-radio "lastfm://artist/" "/fans"] 4 (#$ . 16636) "sArtist: "]) #@58 Inform Last.fm that you love the currently playing song. (defalias 'emms-lastfm-radio-love #[nil "\300\301!\207" [emms-lastfm-radio-rating "love"] 2 (#$ . 16836) nil]) #@66 Inform Last.fm that you want to skip the currently playing song. (defalias 'emms-lastfm-radio-skip #[nil "\300\301!\207" [emms-lastfm-radio-rating "skip"] 2 (#$ . 17010) nil]) #@65 Inform Last.fm that you want to ban the currently playing song. (defalias 'emms-lastfm-radio-ban #[nil "\300\301!\207" [emms-lastfm-radio-rating "ban"] 2 (#$ . 17192) nil]) (defalias 'emms-lastfm-radio-rating #[(command) "\303\304\305 \306\n\307\310\311!\260\312\"\207" [emms-lastfm-radio-base-url emms-lastfm-radio-session command emms-lastfm-http-GET "control.php?" "session=" "&command=" "&debug=" number-to-string 0 emms-lastfm-radio-rating-sentinel] 10]) (defalias 'emms-lastfm-radio-rating-sentinel #[(&rest args) "p\301!\210\302\303\"\304\230\203\305\306!\210\202\305\307!\210\310!)\207" [buffer emms-http-decode-buffer emms-key-value "response" "OK" message "EMMS: Rated current track" "EMMS: Rating failed" kill-buffer] 3]) #@215 Request the metadata of the current song and display it. If FN is given, call it instead of `emms-lastfm-radio-request-metadata-sentinel', with DATA as its first parameter. If DATA is given, it should be a list. (defalias 'emms-lastfm-radio-request-metadata #[(&optional fn data) "\304\305\306 \307\310\311!\260\n\206\312 #\207" [emms-lastfm-radio-base-url emms-lastfm-radio-session fn data emms-lastfm-http-GET "np.php?" "session=" "&debug=" number-to-string 0 emms-lastfm-radio-request-metadata-sentinel] 8 (#$ . 17942) nil]) (defalias 'emms-lastfm-radio-request-metadata-sentinel #[(&rest args) "p\304!\210\305\306\"\305\307\"\310 \311!\210\312 \313 #\210\312 \314\n#\210\315 !,\207" [buffer track title artist emms-http-decode-buffer emms-key-value "artist" "track" emms-playlist-current-selected-track kill-buffer emms-track-set info-artist info-title emms-track-updated] 4]) (defalias 'emms-read-line #[nil "\300\301 \302 \"\207" [buffer-substring-no-properties line-beginning-position line-end-position] 3]) #@141 Returns the value of KEY from BUFFER. If BUFFER is nil, use the current buffer. BUFFER has to contain a key-value list like: foo=bar x=17 (defalias 'emms-key-value #[(key &optional buffer) "\205\302!??\205(r\206pq\210eb\210\303\304 \305Q\306\307#\205'\310`\311 \")\207" [buffer key buffer-live-p re-search-forward "^" "=" nil t buffer-substring-no-properties line-end-position] 4 (#$ . 18978)]) (provide 'emms-lastfm)