fix: avoid icecast xml to be shown on frontend when there is no artist

This commit is contained in:
Luis Pereira 2025-10-14 11:28:23 +01:00 committed by Brian O'Reilly
parent 6506f7d153
commit 136fa2fa74
1 changed files with 4 additions and 2 deletions

View File

@ -857,8 +857,10 @@
(let* ((source-section (subseq xml-string match-start (let* ((source-section (subseq xml-string match-start
(or (cl-ppcre:scan "</source>" xml-string :start match-start) (or (cl-ppcre:scan "</source>" xml-string :start match-start)
(length xml-string)))) (length xml-string))))
(title (or (cl-ppcre:regex-replace-all ".*<title>(.*?)</title>.*" source-section "\\1") "Unknown")) (titlep (cl-ppcre:all-matches "<title>" source-section))
(listeners (or (cl-ppcre:regex-replace-all ".*<listeners>(.*?)</listeners>.*" source-section "\\1") "0"))) (listenersp (cl-ppcre:all-matches "<listeners>" source-section))
(title (if titlep (cl-ppcre:regex-replace-all ".*<title>(.*?)</title>.*" source-section "\\1") "Unknown"))
(listeners (if listenersp (cl-ppcre:regex-replace-all ".*<listeners>(.*?)</listeners>.*" source-section "\\1") "0")))
;; Return JSON in format expected by frontend ;; Return JSON in format expected by frontend
(api-output (api-output
`(("icestats" . (("source" . (("listenurl" . ,(concatenate 'string *stream-base-url* "/asteroid.mp3")) `(("icestats" . (("source" . (("listenurl" . ,(concatenate 'string *stream-base-url* "/asteroid.mp3"))