| 1 | import type { CctvCamera } from './types'; |
| 2 | import { BULGARIA_FWCBG_CAMERAS } from './bulgaria-fwcbg.generated'; |
| 3 | |
| 4 | const BULGARIA_MANUAL: CctvCamera[] = [ |
| 5 | { |
| 6 | id: 'bg-sofia-tsarigradsko-uab', |
| 7 | lat: 42.662, lng: 23.376, |
| 8 | name: 'Tsarigradsko Shose (UAB)', city: 'Sofia', country: 'Bulgaria', |
| 9 | feed_url: 'https://cdn.uab.org/images/cctv/images/cctv/cctv_103/cctv.jpg', |
| 10 | source: 'UAB / KAMEPA', |
| 11 | }, |
| 12 | { |
| 13 | id: 'bg-sofia-banishora', |
| 14 | lat: 42.704, lng: 23.327, |
| 15 | name: 'Banishora / Opalchenska', city: 'Sofia', country: 'Bulgaria', |
| 16 | feed_url: 'https://meteo.chavo.biz/Camera_streem/live_snap.jpg', |
| 17 | source: 'meteo.chavo.biz', |
| 18 | }, |
| 19 | |
| 20 | |
| 21 | { |
| 22 | id: 'bg-burgas-center', |
| 23 | lat: 42.497, lng: 27.47, |
| 24 | name: 'Burgas Center (Smart Burgas HLS)', city: 'Burgas', country: 'Bulgaria', |
| 25 | stream_url: 'https://pics.smartburgas.eu/m3u8/burgas_town_Center.m3u8', |
| 26 | stream_type: 'hls', |
| 27 | external_url: 'https://www.weather-webcam.eu/cams/burgas-centar.html', |
| 28 | source: 'Smart Burgas', |
| 29 | }, |
| 30 | ]; |
| 31 | |
| 32 | function cameraKey(cam: CctvCamera): string { |
| 33 | return (cam.stream_url || cam.feed_url || cam.external_url || cam.id).split('?')[0]; |
| 34 | } |
| 35 | |
| 36 | export async function fetchBulgariaCameras(): Promise<CctvCamera[]> { |
| 37 | const seen = new Set<string>(); |
| 38 | const merged: CctvCamera[] = []; |
| 39 | |
| 40 | for (const cam of [...BULGARIA_MANUAL, ...BULGARIA_FWCBG_CAMERAS]) { |
| 41 | if (!cam.feed_url && !cam.stream_url && !cam.external_url) continue; |
| 42 | const key = cameraKey(cam); |
| 43 | if (seen.has(key)) continue; |
| 44 | seen.add(key); |
| 45 | merged.push(cam); |
| 46 | } |
| 47 | |
| 48 | return merged; |
| 49 | } |