(response ResponseStruct, data bool)
| 1278 | } |
| 1279 | |
| 1280 | func setDefaultResponseData(response ResponseStruct, data bool) (defaults ResponseStruct) { |
| 1281 | |
| 1282 | defaults = response |
| 1283 | |
| 1284 | // Total connections for all playlists |
| 1285 | totalPlaylistCount := 0 |
| 1286 | if len(Settings.Files.M3U) > 0 { |
| 1287 | for _, value := range Settings.Files.M3U { |
| 1288 | |
| 1289 | // Assert that value is a map[string]interface{} |
| 1290 | nestedMap, ok := value.(map[string]interface{}) |
| 1291 | if !ok { |
| 1292 | fmt.Printf("Error asserting nested value as map: %v\n", value) |
| 1293 | continue |
| 1294 | } |
| 1295 | |
| 1296 | // Get the tuner count |
| 1297 | if tuner, exists := nestedMap["tuner"]; exists { |
| 1298 | switch v := tuner.(type) { |
| 1299 | case float64: |
| 1300 | totalPlaylistCount += int(v) |
| 1301 | case int: |
| 1302 | totalPlaylistCount += v |
| 1303 | default: |
| 1304 | } |
| 1305 | } |
| 1306 | } |
| 1307 | } |
| 1308 | |
| 1309 | // Folgende Daten immer an den Client übergeben |
| 1310 | defaults.ClientInfo.ARCH = System.ARCH |
| 1311 | defaults.ClientInfo.EpgSource = Settings.EpgSource |
| 1312 | |
| 1313 | defaults.ClientInfo.DVR = System.Addresses.DVR |
| 1314 | defaults.ClientInfo.M3U = System.Addresses.M3U |
| 1315 | defaults.ClientInfo.XML = System.Addresses.XML |
| 1316 | |
| 1317 | // Use configured STRM directory or fallback to default |
| 1318 | if Settings.StrmDirectory != "" { |
| 1319 | defaults.ClientInfo.StrmDirectory = Settings.StrmDirectory |
| 1320 | } else { |
| 1321 | defaults.ClientInfo.StrmDirectory = System.Folder.Data + "vod/" |
| 1322 | } |
| 1323 | |
| 1324 | defaults.ClientInfo.OS = System.OS |
| 1325 | defaults.ClientInfo.Streams = fmt.Sprintf("%d / %d", len(Data.Streams.Active), len(Data.Streams.All)) |
| 1326 | defaults.ClientInfo.UUID = Settings.UUID |
| 1327 | |
| 1328 | // Safely access WebScreenLog to avoid race conditions |
| 1329 | logMutex.Lock() |
| 1330 | defaults.ClientInfo.Errors = WebScreenLog.Errors |
| 1331 | defaults.ClientInfo.Warnings = WebScreenLog.Warnings |
| 1332 | logMutex.Unlock() |
| 1333 | |
| 1334 | defaults.ClientInfo.ActiveClients = getActiveClientCount() |
| 1335 | defaults.ClientInfo.ActivePlaylist = getActivePlaylistCount() |
| 1336 | defaults.ClientInfo.TotalClients = Settings.Tuner |
| 1337 | defaults.ClientInfo.TotalPlaylist = totalPlaylistCount |
no test coverage detected