push stream to mp3

Started by newdep, April 20, 2007, 05:29:29 AM

Previous topic - Next topic

newdep

a very quick hack ... ;-) but it works...



#!/usr/bin/newlisp

;;

;; save streaming music to local file.mp3

;; enjoy nodep (2) 2006

;;





;; some playlist..raw hack..

(setq playlist (read-file "http://www.garnierstreamingmedia.com/asx/kinkfm.pls">http://www.garnierstreamingmedia.com/asx/kinkfm.pls"))

;; returns -> "[playlist]rnNumberOfEntries=1rnFile1=http://81.173.3.20:80/%5Cr%5Cn">http://81.173.3.20:80/rn"

(regex "=http://(.*):(.*)/rn" playlist)

(setq link (net-connect (string $1) (int $2) ))



;; any playlist, thisone have no additional path, else add PATH to the GET

(net-send link "GET / HTTP/1.0rn")



;; ICY

(net-send link "Icy-MetaData,1rnrn")



;; semi streaming !

(while (net-peek link)

 (net-receive link 'buff 8192) (append-file "x.mp3" buff))



;; need to press ctrl-c to stop this

(exit)





now play with winamp or xmms the x.mp3 file... enjoy..



[edited] now its working ;-)
-- (define? (Cornflakes))

Lutz

#1
thanks for the edit/corrections, now it works ;-), I added a little progress indicator:


;; semi streaming !
(while (net-peek link)
    (print ".")
    (net-receive link 'buff 8192)
    (append-file "x.mp3" buff))


you could plug in one of your curses routines to make that even nicer



Lutz

newdep

#2
..I always liked these kind of indicators, from the old "DOS' days..







(setq indicator '( {|} {/} {-} {} ))



;; a very raw hack!

(setq playlist (read-file "http://www.garnierstreamingmedia.com/asx/kinkfm.pls">http://www.garnierstreamingmedia.com/asx/kinkfm.pls"))

(regex "=http://(.*):(.*)/rn" playlist)

(setq link (net-connect (string $1) (int $2) ))

(net-send link "GET / HTTP/1.0rn")

(net-send link "Icy-MetaData,1rnrn")



(while (net-peek link)

  (print (first (rotate indicator)) "27[D")

  (sleep 200)

  (net-receive link 'buff 8192) (append-file "x.mp3" buff))



(exit)
-- (define? (Cornflakes))