fix(now-playing): Love Radio — online?musicStreamId (per-channel), не history
history/list игнорирует musicStreamId (всегда главный эфир) → все каналы показывали один трек. player/online?musicStreamId отдаёт верный трек канала. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@ import { Interval } from '@nestjs/schedule';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { NowPlayingService } from './now-playing.service';
|
||||
|
||||
interface LoveHistoryItem {
|
||||
interface LoveSong {
|
||||
artistTitle?: string | null;
|
||||
songTitle?: string | null;
|
||||
}
|
||||
@@ -11,8 +11,9 @@ interface LoveHistoryItem {
|
||||
/**
|
||||
* Now-playing для Love Radio. В ICY-потоках вместо трека приходит «onlinestop56k»
|
||||
* (имя мута), поэтому берём текущий трек из их API:
|
||||
* api.loveradio.ru/api/v1/love-radio/player/history/list?musicStreamId={id}&limit=1
|
||||
* (data[0] = последний/текущий). Обложек API не даёт — их подставит наше обогащение.
|
||||
* api.loveradio.ru/api/v1/love-radio/player/online?musicStreamId={id}
|
||||
* (data.song — текущий трек канала; history/list игнорирует id и даёт только главный).
|
||||
* Обложек API не даёт — их подставит наше обогащение.
|
||||
*/
|
||||
@Injectable()
|
||||
export class LoveNowPlayingService {
|
||||
@@ -56,16 +57,16 @@ export class LoveNowPlayingService {
|
||||
if (!id) return;
|
||||
|
||||
const url =
|
||||
`https://api.loveradio.ru/api/v1/love-radio/player/history/list` +
|
||||
`?musicStreamId=${id}&limit=1`;
|
||||
`https://api.loveradio.ru/api/v1/love-radio/player/online` +
|
||||
`?musicStreamId=${id}`;
|
||||
const res = await fetch(url, { headers: this.headers });
|
||||
if (!res.ok) return;
|
||||
|
||||
const json = (await res.json()) as { data?: LoveHistoryItem[] };
|
||||
const cur = json.data?.[0];
|
||||
const json = (await res.json()) as { data?: { song?: LoveSong } };
|
||||
const cur = json.data?.song;
|
||||
const artist = (cur?.artistTitle ?? '').trim();
|
||||
const song = (cur?.songTitle ?? '').trim();
|
||||
if (!artist || !song) return;
|
||||
if (!artist || !song) return; // между треками — не перетираем
|
||||
|
||||
await this.nowPlayingService.ingest({
|
||||
stationDbId: station.id,
|
||||
|
||||
Reference in New Issue
Block a user