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

Function getProviderData

src/provider.go:15–320  ·  view source on GitHub ↗

fileType: Welcher Dateityp soll aktualisiert werden (m3u, hdhr, xml) | fileID: Update einer bestimmten Datei (Provider ID)

(fileType, fileID string)

Source from the content-addressed store, hash-verified

13
14// fileType: Welcher Dateityp soll aktualisiert werden (m3u, hdhr, xml) | fileID: Update einer bestimmten Datei (Provider ID)
15func getProviderData(fileType, fileID string) (err error) {
16
17 var fileExtension, serverFileName string
18 var body = make([]byte, 0)
19 var newProvider = false
20 var dataMap = make(map[string]interface{})
21
22 var saveDateFromProvider = func(fileSource, serverFileName, id string, body []byte) (err error) {
23
24 var data = make(map[string]interface{})
25
26 if value, ok := dataMap[id].(map[string]interface{}); ok {
27 data = value
28 } else {
29 data["id.provider"] = id
30 dataMap[id] = data
31 }
32
33 // Default keys für die Providerdaten
34 var keys = []string{"name", "description", "type", "file." + System.AppName, "file.source", "tuner", "http_proxy.ip", "http_proxy.port", "last.update", "compatibility", "counter.error", "counter.download", "provider.availability"}
35
36 for _, key := range keys {
37
38 if _, ok := data[key]; !ok {
39
40 switch key {
41
42 case "name":
43 data[key] = serverFileName
44
45 case "description":
46 data[key] = ""
47
48 case "type":
49 data[key] = fileType
50
51 case "file." + System.AppName:
52 data[key] = id + fileExtension
53
54 case "file.source":
55 data[key] = fileSource
56
57 case "http_proxy.ip":
58 data[key] = ""
59
60 case "http_proxy.port":
61 data[key] = ""
62
63 case "last.update":
64 data[key] = time.Now().Format("2006-01-02 15:04:05")
65
66 case "tuner":
67 if fileType == "m3u" || fileType == "hdhr" {
68 if _, ok := data[key].(float64); !ok {
69 data[key] = 1
70 }
71 }
72

Callers 7

maintenanceFunction · 0.85
StartSystemFunction · 0.85
saveFilesFunction · 0.85
updateFileFunction · 0.85
saveWizardFunction · 0.85
APIFunction · 0.85
updateUrlsJsonFunction · 0.85

Calls 12

extractGZIPFunction · 0.85
ShowErrorFunction · 0.85
showInfoFunction · 0.85
jsonToInterfaceFunction · 0.85
checkXMLCompatibilityFunction · 0.85
writeByteToFileFunction · 0.85
downloadFileFromServerFunction · 0.85
checkFileFunction · 0.85
readByteFromFileFunction · 0.85
showWarningFunction · 0.85
getFilenameFromPathFunction · 0.70
saveSettingsFunction · 0.70

Tested by

no test coverage detected