-
Notifications
You must be signed in to change notification settings - Fork 1
/
queue.go
69 lines (49 loc) · 1.15 KB
/
queue.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
66
67
68
69
package main
import (
"container/list"
"encoding/json"
"fmt"
"time"
"github.com/Adeithe/go-twitch/api"
)
var queue list.List = list.List{}
func process() {
var next *list.Element
for queueItem := queue.Front(); queueItem != nil; queueItem = next {
video := queueItem.Value.(api.Video)
var duration time.Duration = video.Duration.AsDuration()
if (duration < time.Minute * 5) {
duration = 0
} else {
duration = duration - time.Minute * 5
}
vod, err := downloadVod(duration, video.URL)
if err != nil {
panic(err)
}
vodAudio, err := convert(vod)
if err != nil {
panic(err)
}
transcription, err := transcribe(vodAudio)
if err != nil {
panic(err)
}
upcoming, err := classify(transcription.Text, video)
if err != nil {
panic(err)
}
transcriptionJson, err := json.Marshal(transcription)
if err != nil {
fmt.Println(err)
return
}
persist(string(transcriptionJson), video, upcoming.Dates, duration)
fmt.Printf("Vod \"%s\" processed successfully.\n", video.ID)
next = queueItem.Next()
queue.Remove(queueItem)
}
}
func addToQueue(vod *api.Video) {
queue.PushBack(*vod)
}