feat(now-playing): Радио Монте-Карло через Крутой Медиа API
Все 21 канал Монте-Карло — сеть Крутой Медиа (dfm.ru/api/n/current). Добавил genre='Radio Monte Carlo' в DfmNowPlayingService, матчинг по слагу из маута потока (basename без битрейта: blues96.aacp -> blues), исключил из ICY-поллера. Чинит 5 каналов, залипших на 'Дух — Тишина' (Blues, Chill Lounge, Italiano, Meditation, Summertime).
This commit is contained in:
@@ -62,9 +62,10 @@ export class DfmNowPlayingService {
|
|||||||
|
|
||||||
@Interval(30000)
|
@Interval(30000)
|
||||||
async pollDfmNowPlaying() {
|
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({
|
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;
|
if (stations.length === 0) return;
|
||||||
|
|
||||||
@@ -96,9 +97,14 @@ export class DfmNowPlayingService {
|
|||||||
for (const station of stations) {
|
for (const station of stations) {
|
||||||
const n = this.norm(station.name);
|
const n = this.norm(station.name);
|
||||||
const aliasSlug = this.alias[n];
|
const aliasSlug = this.alias[n];
|
||||||
|
// Слаг из маута потока (basename без битрейта) — основной ключ для
|
||||||
|
// Монте-Карло (имя станции не совпадает с API-слагом, а маут совпадает:
|
||||||
|
// `mccovers96.aacp` → `mccovers`, `blues96.aacp` → `blues`).
|
||||||
|
const mount = this.mountSlug(station.streamUrl);
|
||||||
const cur =
|
const cur =
|
||||||
idx.get(n) ??
|
idx.get(n) ??
|
||||||
idx.get(n.replace(/-/g, '')) ??
|
idx.get(n.replace(/-/g, '')) ??
|
||||||
|
(mount ? idx.get(mount) : undefined) ??
|
||||||
(aliasSlug ? data[aliasSlug]?.current : undefined);
|
(aliasSlug ? data[aliasSlug]?.current : undefined);
|
||||||
if (!cur?.artist || !cur?.title) continue;
|
if (!cur?.artist || !cur?.title) continue;
|
||||||
|
|
||||||
@@ -133,4 +139,11 @@ export class DfmNowPlayingService {
|
|||||||
.replace(/[^a-z0-9а-я]+/gi, '-')
|
.replace(/[^a-z0-9а-я]+/gi, '-')
|
||||||
.replace(/^-|-$/g, '');
|
.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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export class IcyNowPlayingService {
|
|||||||
const where = {
|
const where = {
|
||||||
recordStationId: null,
|
recordStationId: null,
|
||||||
isOnline: true,
|
isOnline: true,
|
||||||
genre: { notIn: ['DFM', 'MAXIMUM', 'Love Radio'] },
|
genre: { notIn: ['DFM', 'MAXIMUM', 'Love Radio', 'Radio Monte Carlo'] },
|
||||||
NOT: { streamUrl: { contains: 'emgsound.ru' } },
|
NOT: { streamUrl: { contains: 'emgsound.ru' } },
|
||||||
};
|
};
|
||||||
const total = await this.prisma.station.count({ where });
|
const total = await this.prisma.station.count({ where });
|
||||||
|
|||||||
Reference in New Issue
Block a user