-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
81 lines (64 loc) · 1.54 KB
/
main.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
70
71
72
73
74
75
76
77
78
79
80
81
package main
import (
"fmt"
"image"
"strings"
config "youtube-slideshow/configuration"
fg "youtube-slideshow/frameGenerator"
movmk "youtube-slideshow/movieMaker"
prsr "youtube-slideshow/parser"
)
func main() {
city := "Италия" //os.Args[1]
cfg := "" //os.Args[2]
config.InitConfiguration(cfg)
go generateMoviesForAllHotelsByCountry(city)
<-config.EndCh
}
func createParser() PhotoParser {
var parser PhotoParser
hotelPrsr := new(prsr.HotelParser)
hotelPrsr.InitConfig()
parser = hotelPrsr
return parser
}
func createFrameGenerator() FrameGenerator {
var frameGen FrameGenerator
frGen := new(fg.FrameGenerator)
frGen.InitConfig()
frameGen = frGen
return frameGen
}
func createMovieMaker() MovieMaker {
var mmk MovieMaker
mm := new(movmk.MovieMaker)
mmk = mm
return mmk
}
func generateMoviesForAllHotelsByCountry(country string) {
parser := createParser()
go parser.ParseHotelsByCountry(country)
go func() {
var photosPath string
for {
select {
case photosPath = <-config.ParsedHotels:
framesCh := make(chan image.Image)
stopCh := make(chan bool)
movieMaker := new(movmk.MovieMaker)
movieMaker.FramesCh = framesCh
movieMaker.Stop = stopCh
go movieMaker.MakeMovie(photosPath[strings.LastIndex(photosPath, "/")+1:])
frGen := new(fg.FrameGenerator)
frGen.InitConfig()
frGen.FramesCh = framesCh
frGen.StopCh = stopCh
frGen.GenerateFrames(photosPath)
case <-config.Quit:
config.Parsed = true
fmt.Println("Everything is parsed")
return
}
}
}()
}