Fixes media player's problem with apostrophes.
This commit is contained in:
@@ -3,6 +3,11 @@ import { CommonModule } from '@angular/common';
|
|||||||
|
|
||||||
import { StationConfigService } from '../services/station-config.service';
|
import { StationConfigService } from '../services/station-config.service';
|
||||||
|
|
||||||
|
/** Decode malformed HTML entities from stream metadata (e.g. `&039;` → `'`). */
|
||||||
|
function decodeMetadata(text: string): string {
|
||||||
|
return text.replace(/'/g, "'");
|
||||||
|
}
|
||||||
|
|
||||||
/** Shape of the Airtime live-info JSON response (subset of fields we use). */
|
/** Shape of the Airtime live-info JSON response (subset of fields we use). */
|
||||||
interface LiveInfoResponse {
|
interface LiveInfoResponse {
|
||||||
current: {
|
current: {
|
||||||
@@ -103,14 +108,14 @@ export class MediaPlayerComponent implements OnDestroy {
|
|||||||
if (!resp.ok) throw new Error('Metadata fetch failed');
|
if (!resp.ok) throw new Error('Metadata fetch failed');
|
||||||
const data: LiveInfoResponse = await resp.json();
|
const data: LiveInfoResponse = await resp.json();
|
||||||
|
|
||||||
const showName = data.currentShow?.[0]?.name ?? '';
|
const showName = decodeMetadata(data.currentShow?.[0]?.name ?? '');
|
||||||
const current = data.current;
|
const current = data.current;
|
||||||
const trackTitle = current?.metadata?.track_title ?? '';
|
const trackTitle = decodeMetadata(current?.metadata?.track_title ?? '');
|
||||||
const artistName = current?.metadata?.artist_name ?? '';
|
const artistName = decodeMetadata(current?.metadata?.artist_name ?? '');
|
||||||
|
|
||||||
let track = '';
|
let track = '';
|
||||||
if (artistName && trackTitle) track = `${artistName} - ${trackTitle}`;
|
if (artistName && trackTitle) track = `${artistName} - ${trackTitle}`;
|
||||||
else if (current?.name) track = current.name;
|
else if (current?.name) track = decodeMetadata(current.name);
|
||||||
else if (trackTitle) track = trackTitle;
|
else if (trackTitle) track = trackTitle;
|
||||||
|
|
||||||
this.showName.set(showName);
|
this.showName.set(showName);
|
||||||
|
|||||||
Reference in New Issue
Block a user