[BLXF] OPGELET, nieuwe upgraded whichstation.el (voor GNU/Emacs)

[ Thread Index | Date Index | More lists.tuxfamily.org/blxf Archives ]


Opgelet, de Emacs versie van whichstation.el van vandaag, bevat een klein
foutje, vandaar deze extra bijlage, u hoeft enkel het pakket uit de tgz te
vervangen: maak het scriptje executable en kopiëer het naar /usb/local/bin

Aldo.

(bijlage)  

-- 
  |  Verstuurd vanaf mijn GNU/Linux  |  Envoyé de mon GNU/Linux  | 
  |  -----------------  Sent from GNU/Linux  ------------------  | 
;;; whichstation.el ---  
;;  
;; Emacs adaptation
;;
;; original :
;; Which(/Rec/Prog/EU)Station - The ultimate easy radio station streaming script
;; O. La Rosa - http://www.blinuxman.net - Started 19-06-2004 - Public 
;; Latest release & more tech spex / info: cf. whichstation.README 
;; Based on a script found here: news:be.comp.os.linux 
;; Please visit http://blinuxman.net/ providing us with new URLs. 
;; Also feel free to visit last.fm, iheard.com or listenlive.eu to help us 
;; with keeping this package up-to-date !
;; 
;; adaptation for Emacs :
;; E. Bliesenick (erwb19@xxxxxxx)
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
;; 
;; This program is free software; you can redistribute it 
;; and/or modify it under the terms of the GNU General Public 
;; License as published by the Free Software Foundation; 
;; either version 2, or (at your option) any later version. 
;; 
;; This program is distributed in the hope that it will be 
;; useful, but WITHOUT ANY WARRANTY; without even the implied 
;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
;; PURPOSE. 
;; 
;; See the GNU General Public License for more details. 
;; 
;; You should have received a copy of the GNU General Public 
;; License along with this program; see the file COPYING. 
;; 
;; If not, write to the Free Software Foundation, Inc., 51 
;; Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 
;; 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
;; 
;;; Commentary:
;;; listen french radios 
;; 
;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:
;; 

(require 'alist)
(require 'cl)

(defun affiche-liste-radios ()
  "affiche la liste des principales radios du pays sélectionné dans un buffer dédié"
  (switch-to-buffer "radios")
  (erase-buffer)
  (princ "Exit\n" (get-buffer "radios"))
  (princ "----\n" (get-buffer "radios"))
  (setq list radios-alist)
  (while list
    (princ (caar list) (get-buffer "radios"))
    (princ "\n" (get-buffer "radios"))
    (setq list (cdr list)))
    (beginning-of-buffer)
)

(defun cree-liste-radios (file)
   "Lit le fichier des stations du pays sélectionné (ex eustation.fr.lst pour la France)
    et crée la liste associative nom-radio -> site"
    (setq radios-alist (make-list 0 nil))
     (with-temp-buffer
       (insert-file-contents file)
       (goto-char (point-min))
       (while (not (eobp))
		(setq p1 (line-beginning-position) )
		(setq p2 (line-end-position) )
		(setq ligne (buffer-substring-no-properties p1 p2))
		
		(save-match-data
			(and (string-match "^\\(.*\\)\\ \\#[ 0-9]+\\(.*\\)$" ligne) 
				(setq 	adresse (match-string 1 ligne)
						nom (match-string 2 ligne) 		
				) 
			)
			(set-alist 'radios-alist nom adresse)
		)
		
		(forward-line)
	   )
     )
   (setq radios-alist (nreverse radios-alist))
   (affiche-liste-radios)
)
 
 (defun lance-ou-quitte ()
   "lance l'écoute de la radio sélectionnée ou quitte le programme d'écoute"
   (switch-to-buffer "radios")
   (if (get-process "son") 
		(delete-process "son"))
	(let 
		(p1 p2 ligne)
		(setq p1 (line-beginning-position) )
		(setq p2 (line-end-position) )
		(setq ligne (buffer-substring-no-properties p1 p2))
		(if (string-equal ligne "Exit")
			(progn 
			    (if (get-process "son")
					(delete-process "son"))
				(if (get-buffer "radios")
					(kill-buffer "radios"))
			)
		  (setq url (cdr (assoc ligne radios-alist)))
		  (start-process-shell-command "son" nil 
		  (concat "mplayer -vo null -af volnorm=2 -nortc -cache 256 -cache-min 6 -cache-seek-min 55 -ao oss,alsa -osdlevel 1 -nojoystick -nolirc " url))
		)
	)
 )
 
 (defun affiche-radios ()
	"fonction de départ (entry function) lancée par une touche (exemple F9)
	si la liste des radios n'est pas affichée,
	on choisit le pays (fr, be, de ou nl), on lit le fichier des stations correspondant (eustation.<pays>.lst)
	et on l'affiche dans le buffer radios, créé pour l'occasion
	on peut naviguer avec les touches flèches haut et bas dans la liste
	ensuite, un 2ème appui sur F9 lance l'écoute de la radio sur laquelle est positionné le curseur"
	(interactive)
	(if (not (get-buffer "radios"))
		( progn 
			(loop do
				(setq pays (read-from-minibuffer "Quel pays (fr, be, ch, de, nl ou C-g) : "))
			until (or 
					(string-equal pays "fr") (string-equal pays "de") (string-equal pays "ch")
					(string-equal pays "nl") (string-equal pays "be")))
			(cree-liste-radios (concat "/usr/local/bin/eustation." pays ".lst"))	
			(read-only-mode)
		)
	  (lance-ou-quitte)
	) 
 )

;;;  -- Provide

(provide 'whichstation)

;;;  -- End Provide


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/