This repository has been archived by the owner on Sep 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.go
71 lines (66 loc) · 2.32 KB
/
parser.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
package parser
import (
"net/http"
"time"
"github.com/rl404/go-malscraper/internal/parser/anime"
"github.com/rl404/go-malscraper/internal/parser/article"
"github.com/rl404/go-malscraper/internal/parser/character"
"github.com/rl404/go-malscraper/internal/parser/club"
"github.com/rl404/go-malscraper/internal/parser/genre"
"github.com/rl404/go-malscraper/internal/parser/manga"
"github.com/rl404/go-malscraper/internal/parser/news"
"github.com/rl404/go-malscraper/internal/parser/people"
producermagazine "github.com/rl404/go-malscraper/internal/parser/producer_magazine"
"github.com/rl404/go-malscraper/internal/parser/recommendation"
"github.com/rl404/go-malscraper/internal/parser/review"
"github.com/rl404/go-malscraper/internal/parser/search"
"github.com/rl404/go-malscraper/internal/parser/top"
"github.com/rl404/go-malscraper/internal/parser/user"
"github.com/rl404/go-malscraper/service"
)
// Requester is mockable http client.
type Requester interface {
Do(*http.Request) (*http.Response, error)
}
// Parser parse MyAnimeList web amd convert to easy-to-use data.
type Parser struct {
anime anime.Parser
manga manga.Parser
character character.Parser
people people.Parser
producer producermagazine.Parser
genre genre.Parser
review review.Parser
recommendation recommendation.Parser
news news.Parser
article article.Parser
club club.Parser
top top.Parser
user user.Parser
search search.Parser
logger service.Logger
http Requester
}
// New to create new parser.
func New(cleanImg, cleanVid bool, l service.Logger) service.API {
return &Parser{
anime: anime.New(cleanImg, cleanVid),
manga: manga.New(cleanImg),
character: character.New(cleanImg),
people: people.New(cleanImg),
producer: producermagazine.New(cleanImg),
genre: genre.New(cleanImg),
review: review.New(cleanImg),
recommendation: recommendation.New(cleanImg),
news: news.New(cleanImg),
article: article.New(cleanImg),
club: club.New(cleanImg),
top: top.New(cleanImg),
user: user.New(cleanImg),
search: search.New(cleanImg),
logger: l,
http: &http.Client{
Timeout: 10 * time.Second,
},
}
}