fix: Restore live stream metadata display on web interface
- Fix Icecast API endpoint to use proper HTTP basic authentication - Handle both string and byte responses from drakma:http-request - Parse XML response to extract track title and listener count - Return JSON in format expected by frontend JavaScript Now Playing info now updates correctly on both front page and player page: - Shows current track (e.g. 'Vector Lovers - Boulevard') - Updates every 10 seconds automatically - Displays real-time listener counts AAC streaming feature is now complete with full live metadata integration.
This commit is contained in:
parent
4c41777823
commit
88762d3bfc
|
|
@ -315,10 +315,32 @@
|
|||
"Get live status from Icecast server"
|
||||
(setf (radiance:header "Content-Type") "application/json")
|
||||
(handler-case
|
||||
(let* ((icecast-url "http://localhost:8000/status-json.xsl")
|
||||
(response (drakma:http-request icecast-url :want-stream nil)))
|
||||
(let* ((icecast-url "http://localhost:8000/admin/stats.xml")
|
||||
(response (drakma:http-request icecast-url
|
||||
:want-stream nil
|
||||
:basic-authorization '("admin" "asteroid_admin_2024"))))
|
||||
(if response
|
||||
(babel:octets-to-string response :encoding :utf-8) ; Convert response to string
|
||||
(let ((xml-string (if (stringp response)
|
||||
response
|
||||
(babel:octets-to-string response :encoding :utf-8))))
|
||||
;; Simple XML parsing to extract source information
|
||||
;; Look for <source mount="/asteroid.mp3"> sections and extract title, listeners, etc.
|
||||
(multiple-value-bind (match-start match-end)
|
||||
(cl-ppcre:scan "<source mount=\"/asteroid\\.mp3\">" xml-string)
|
||||
(if match-start
|
||||
(let* ((source-section (subseq xml-string match-start
|
||||
(or (cl-ppcre:scan "</source>" xml-string :start match-start)
|
||||
(length xml-string))))
|
||||
(title (or (cl-ppcre:regex-replace-all ".*<title>(.*?)</title>.*" source-section "\\1") "Unknown"))
|
||||
(listeners (or (cl-ppcre:regex-replace-all ".*<listeners>(.*?)</listeners>.*" source-section "\\1") "0")))
|
||||
;; Return JSON in format expected by frontend
|
||||
(cl-json:encode-json-to-string
|
||||
`(("icestats" . (("source" . (("listenurl" . "http://localhost:8000/asteroid.mp3")
|
||||
("title" . ,title)
|
||||
("listeners" . ,(parse-integer listeners :junk-allowed t)))))))))
|
||||
;; No source found, return empty
|
||||
(cl-json:encode-json-to-string
|
||||
`(("icestats" . (("source" . nil))))))))
|
||||
(cl-json:encode-json-to-string
|
||||
`(("error" . "Could not connect to Icecast server")))))
|
||||
(error (e)
|
||||
|
|
|
|||
Loading…
Reference in New Issue