-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
55 lines (45 loc) · 1.04 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
package main
import (
"flag"
"fmt"
"net/http"
"time"
"github.com/riffaudo/movie-recommendations/movie"
)
var (
storage movie.Storage
)
func init() {
response, err := http.Get("http://pastebin.com/raw/cVyp3McN")
if err != nil {
fmt.Println(err)
return
}
defer response.Body.Close()
storage, err = movie.StorageFromReader(response.Body)
if err != nil {
fmt.Println(err)
return
}
}
func main() {
genre := flag.String("genre", "", "Movie genre to return: Action, Animation")
showing := flag.String("showing", "", "Showing time, format 10:00")
flag.Parse()
searchParams := movie.SearchParams{}
if *genre != "" {
searchParams.Genre = *genre
}
if *showing != "" {
s, err := time.ParseInLocation("15:04", *showing, time.Local) // parse time in current timezone
if err != nil {
fmt.Println("Error Parsing date, should use format: 15:04")
return
}
s = s.Add(-time.Minute * 30)
searchParams.Showing = s
}
for _, m := range storage.Load(searchParams) {
fmt.Println(m.DisplayNextShowing(searchParams.Showing))
}
}