forked from webtor-io/web-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.go
More file actions
42 lines (34 loc) · 993 Bytes
/
common.go
File metadata and controls
42 lines (34 loc) · 993 Bytes
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
package main
import (
"github.com/urfave/cli"
cs "github.com/webtor-io/common-services"
"github.com/webtor-io/web-ui/services/api"
enr "github.com/webtor-io/web-ui/services/enrich"
ku "github.com/webtor-io/web-ui/services/kinopoisk_unofficial"
"github.com/webtor-io/web-ui/services/omdb"
"net/http"
)
func configureEnricher(f []cli.Flag) []cli.Flag {
f = omdb.RegisterFlags(f)
f = ku.RegisterFlags(f)
return f
}
func makeEnricher(c *cli.Context, cl *http.Client, pg *cs.PG, sapi *api.Api) *enr.Enricher {
var mdMappers []enr.MetadataMapper
// Setting OMDB API
omdbApi := omdb.New(c, cl)
// Setting OMDB Mapper
om := enr.NewOMDB(pg, omdbApi)
if om != nil {
mdMappers = append(mdMappers, om)
}
// Setting Kinopoisk Unofficial API
kpuApi := ku.New(c, cl)
// Setting Kinopoisk Unofficial Mapper
kpu := enr.NewKinopoiskUnofficial(pg, kpuApi)
if kpu != nil {
mdMappers = append(mdMappers, kpu)
}
// Setting Enricher
return enr.NewEnricher(pg, sapi, mdMappers)
}