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';
|
||||
|
||||
/** 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). */
|
||||
interface LiveInfoResponse {
|
||||
current: {
|
||||
@@ -103,14 +108,14 @@ export class MediaPlayerComponent implements OnDestroy {
|
||||
if (!resp.ok) throw new Error('Metadata fetch failed');
|
||||
const data: LiveInfoResponse = await resp.json();
|
||||
|
||||
const showName = data.currentShow?.[0]?.name ?? '';
|
||||
const showName = decodeMetadata(data.currentShow?.[0]?.name ?? '');
|
||||
const current = data.current;
|
||||
const trackTitle = current?.metadata?.track_title ?? '';
|
||||
const artistName = current?.metadata?.artist_name ?? '';
|
||||
const trackTitle = decodeMetadata(current?.metadata?.track_title ?? '');
|
||||
const artistName = decodeMetadata(current?.metadata?.artist_name ?? '');
|
||||
|
||||
let track = '';
|
||||
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;
|
||||
|
||||
this.showName.set(showName);
|
||||
|
||||
Reference in New Issue
Block a user