diff --git a/src/now-playing/dfm-now-playing.service.ts b/src/now-playing/dfm-now-playing.service.ts index 1d0e28c..32009ef 100644 --- a/src/now-playing/dfm-now-playing.service.ts +++ b/src/now-playing/dfm-now-playing.service.ts @@ -62,9 +62,10 @@ export class DfmNowPlayingService { @Interval(30000) async pollDfmNowPlaying() { - // DFM и MAXIMUM — обе сети Крутой Медиа, общий API dfm.ru/api/n/current + // DFM, MAXIMUM и Радио Монте-Карло — все сети Крутой Медиа, общий API + // dfm.ru/api/n/current const stations = await this.prisma.station.findMany({ - where: { genre: { in: ['DFM', 'MAXIMUM'] } }, + where: { genre: { in: ['DFM', 'MAXIMUM', 'Radio Monte Carlo'] } }, }); if (stations.length === 0) return; @@ -96,9 +97,14 @@ export class DfmNowPlayingService { for (const station of stations) { const n = this.norm(station.name); const aliasSlug = this.alias[n]; + // Слаг из маута потока (basename без битрейта) — основной ключ для + // Монте-Карло (имя станции не совпадает с API-слагом, а маут совпадает: + // `mccovers96.aacp` → `mccovers`, `blues96.aacp` → `blues`). + const mount = this.mountSlug(station.streamUrl); const cur = idx.get(n) ?? idx.get(n.replace(/-/g, '')) ?? + (mount ? idx.get(mount) : undefined) ?? (aliasSlug ? data[aliasSlug]?.current : undefined); if (!cur?.artist || !cur?.title) continue; @@ -133,4 +139,11 @@ export class DfmNowPlayingService { .replace(/[^a-z0-9а-я]+/gi, '-') .replace(/^-|-$/g, ''); } + + // Слаг из маута потока: basename пути без расширения и хвостового битрейта. + // `http://mc-blues.hostingradio.ru/blues96.aacp` → `blues`. + private mountSlug(streamUrl: string): string | null { + const m = streamUrl.match(/\/([a-z0-9_-]+?)\d*\.(?:aacp|aac|mp3|m3u8)/i); + return m ? m[1].toLowerCase() : null; + } } diff --git a/src/now-playing/icy-now-playing.service.ts b/src/now-playing/icy-now-playing.service.ts index b4de699..1d93e7b 100644 --- a/src/now-playing/icy-now-playing.service.ts +++ b/src/now-playing/icy-now-playing.service.ts @@ -29,7 +29,7 @@ export class IcyNowPlayingService { const where = { recordStationId: null, isOnline: true, - genre: { notIn: ['DFM', 'MAXIMUM', 'Love Radio'] }, + genre: { notIn: ['DFM', 'MAXIMUM', 'Love Radio', 'Radio Monte Carlo'] }, NOT: { streamUrl: { contains: 'emgsound.ru' } }, }; const total = await this.prisma.station.count({ where });