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