MCPcopy Index your code
hub / github.com/Threadfin/Threadfin / createDummyProgram

Function createDummyProgram

src/xepg.go:1512–1617  ·  view source on GitHub ↗

Dummy Daten erstellen (createXMLTVFile)

(xepgChannel XEPGChannelStruct)

Source from the content-addressed store, hash-verified

1510
1511// Dummy Daten erstellen (createXMLTVFile)
1512func createDummyProgram(xepgChannel XEPGChannelStruct) (dummyXMLTV XMLTV) {
1513 if xepgChannel.XMapping == "PPV" {
1514 var channelID = xepgChannel.XMapping
1515 programs := createLiveProgram(xepgChannel, channelID)
1516 dummyXMLTV.Program = programs
1517 return
1518 }
1519
1520 var imgc = Data.Cache.Images
1521 var currentTime = time.Now()
1522 var dateArray = strings.Fields(currentTime.String())
1523 var offset = " " + dateArray[2]
1524 var currentDay = currentTime.Format("20060102")
1525 var startTime, _ = time.Parse("20060102150405", currentDay+"000000")
1526
1527 showInfo("Create Dummy Guide:" + "Time offset" + offset + " - " + xepgChannel.XName)
1528
1529 var dummyLength int = 30 // Default to 30 minutes if parsing fails
1530 var err error
1531 var dl = strings.Split(xepgChannel.XMapping, "_")
1532 if dl[0] != "" {
1533 // Check if the first part is a valid integer
1534 if match, _ := regexp.MatchString(`^\d+$`, dl[0]); match {
1535 dummyLength, err = strconv.Atoi(dl[0])
1536 if err != nil {
1537 ShowError(err, 000)
1538 // Continue with default value instead of returning
1539 }
1540 } else {
1541 // For non-numeric formats that aren't "PPV" (which is handled above),
1542 // use the default value
1543 showDebug(fmt.Sprintf("Non-numeric format for XMapping: %s, using default duration of 30 minutes", xepgChannel.XMapping), 1)
1544 }
1545 }
1546
1547 for d := 0; d < 4; d++ {
1548
1549 var epgStartTime = startTime.Add(time.Hour * time.Duration(d*24))
1550
1551 for t := dummyLength; t <= 1440; t = t + dummyLength {
1552
1553 var epgStopTime = epgStartTime.Add(time.Minute * time.Duration(dummyLength))
1554
1555 var epg Program
1556 poster := Poster{}
1557
1558 epg.Channel = xepgChannel.XMapping
1559 epg.Start = epgStartTime.Format("20060102150405") + offset
1560 epg.Stop = epgStopTime.Format("20060102150405") + offset
1561
1562 // Create title with proper handling of non-ASCII characters
1563 var titleValue = xepgChannel.XName + " (" + epgStartTime.Weekday().String()[0:2] + ". " + epgStartTime.Format("15:04") + " - " + epgStopTime.Format("15:04") + ")"
1564 if !Settings.EnableNonAscii {
1565 titleValue = strings.TrimSpace(strings.Map(func(r rune) rune {
1566 if r > unicode.MaxASCII {
1567 return -1
1568 }
1569 return r

Callers 1

getProgramDataFunction · 0.85

Calls 4

createLiveProgramFunction · 0.85
showInfoFunction · 0.85
ShowErrorFunction · 0.85
showDebugFunction · 0.85

Tested by

no test coverage detected