XEPG Datenbank erstellen / aktualisieren
(completionChan chan<- bool)
| 347 | |
| 348 | // XEPG Datenbank erstellen / aktualisieren |
| 349 | func createXEPGDatabase(completionChan chan<- bool) (err error) { |
| 350 | |
| 351 | // Protect against concurrent access to XEPG data structures |
| 352 | xepgMutex.Lock() |
| 353 | defer xepgMutex.Unlock() |
| 354 | |
| 355 | // Send initial progress update - continue from previous progress |
| 356 | if globalXEPGProgress > 0 { |
| 357 | showInfo(fmt.Sprintf("XEPG: Continuing from previous progress (%d%%)", globalXEPGProgress)) |
| 358 | } |
| 359 | globalXEPGProgress = 40 |
| 360 | broadcastProgressUpdate(ProcessingProgress{ |
| 361 | Percentage: globalXEPGProgress, |
| 362 | Current: 0, |
| 363 | Total: len(Data.Streams.Active), |
| 364 | Operation: "Rebuilding XEPG Database - Starting", |
| 365 | IsProcessing: true, |
| 366 | }) |
| 367 | |
| 368 | var allChannelNumbers = make([]float64, 0, System.UnfilteredChannelLimit) |
| 369 | Data.Cache.Streams.Active = make([]string, 0, System.UnfilteredChannelLimit) |
| 370 | Data.XEPG.Channels = make(map[string]interface{}, System.UnfilteredChannelLimit) |
| 371 | |
| 372 | // Clear streaming URL cache |
| 373 | Data.Cache.StreamingURLS = make(map[string]StreamInfo) |
| 374 | saveMapToJSONFile(System.File.URLS, Data.Cache.StreamingURLS) |
| 375 | |
| 376 | Data.Cache.Streams.Active = make([]string, 0, System.UnfilteredChannelLimit) |
| 377 | Settings = SettingsStruct{} |
| 378 | Data.XEPG.Channels, err = loadJSONFileToMap(System.File.XEPG) |
| 379 | if err != nil { |
| 380 | ShowError(err, 1004) |
| 381 | return err |
| 382 | } |
| 383 | |
| 384 | settings, err := loadJSONFileToMap(System.File.Settings) |
| 385 | if err != nil || len(settings) == 0 { |
| 386 | return |
| 387 | } |
| 388 | settings_json, _ := json.Marshal(settings) |
| 389 | json.Unmarshal(settings_json, &Settings) |
| 390 | |
| 391 | // Get current M3U channels |
| 392 | m3uChannels := make(map[string]M3UChannelStructXEPG) |
| 393 | for _, dsa := range Data.Streams.Active { |
| 394 | var m3uChannel M3UChannelStructXEPG |
| 395 | err = json.Unmarshal([]byte(mapToJSON(dsa)), &m3uChannel) |
| 396 | if err == nil { |
| 397 | // Use tvg-id as the key for matching channels |
| 398 | key := m3uChannel.TvgID |
| 399 | if key == "" { |
| 400 | key = m3uChannel.TvgName |
| 401 | } |
| 402 | m3uChannels[key] = m3uChannel |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | // Update URLs in XEPG database |
no test coverage detected