-
Notifications
You must be signed in to change notification settings - Fork 0
/
studio.go
65 lines (56 loc) · 1.25 KB
/
studio.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import (
"encoding/csv"
"log"
"os"
"strconv"
)
func readData(fileName string) ([][]string, error) {
f, err := os.Open(fileName)
if err != nil {
return [][]string{}, err
}
defer f.Close()
r := csv.NewReader(f)
records, err := r.ReadAll()
if err != nil {
return [][]string{}, err
}
return records, nil
}
func getIDtoStudio(file string) map[int]string {
records, err := readData(file)
if err != nil {
log.Fatal(err)
}
stid := make(map[int]string)
for _, record := range records {
id, err := strconv.Atoi(record[0])
if err != nil {
log.Printf("could'nt parse %v to integer", record[0])
continue
}
stid[id] = record[1]
}
return stid
}
func getStudioIngestURL(file string) map[string]string {
studioIngestUrls := make(map[string]string)
records, err := readData(file)
if err != nil {
log.Fatal(err)
}
for _, record := range records {
studioIngestUrls[record[1]] = record[2]
}
return studioIngestUrls
}
func getTalkIngestURL(talkidtostudio string, studiotourl string) map[int]string {
talks := getIDtoStudio(talkidtostudio)
studios := getStudioIngestURL(studiotourl)
talkIngestURLs := make(map[int]string)
for id, studio := range talks {
talkIngestURLs[id] = studios[studio]
}
return talkIngestURLs
}