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
/
people.go
71 lines (62 loc) · 2.29 KB
/
people.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"
"github.com/rl404/go-malscraper/model"
"github.com/rl404/go-malscraper/pkg/utils"
)
// GetPeople to get people details.
func (p *Parser) GetPeople(id int) (*model.People, int, error) {
doc, code, err := p.getDoc(utils.BuildURL(malURL, "people", id), "#contentWrapper")
if err != nil {
return nil, code, err
}
return p.people.GetDetails(doc), http.StatusOK, nil
}
// GetPeopleCharacter to get people anime character list.
func (p *Parser) GetPeopleCharacter(id int) ([]model.PeopleCharacter, int, error) {
doc, code, err := p.getDoc(utils.BuildURL(malURL, "people", id), "#contentWrapper")
if err != nil {
return nil, code, err
}
return p.people.GetCharacters(doc), http.StatusOK, nil
}
// GetPeopleStaff to get people anime staff list.
func (p *Parser) GetPeopleStaff(id int) ([]model.Role, int, error) {
doc, code, err := p.getDoc(utils.BuildURL(malURL, "people", id), "#contentWrapper")
if err != nil {
return nil, code, err
}
return p.people.GetStaffManga(doc, "staff"), http.StatusOK, nil
}
// GetPeopleManga to get people published manga list.
func (p *Parser) GetPeopleManga(id int) ([]model.Role, int, error) {
doc, code, err := p.getDoc(utils.BuildURL(malURL, "people", id), "#contentWrapper")
if err != nil {
return nil, code, err
}
return p.people.GetStaffManga(doc, "manga"), http.StatusOK, nil
}
// GetPeopleNews to get people news list.
func (p *Parser) GetPeopleNews(id int) ([]model.NewsItem, int, error) {
doc, code, err := p.getDoc(utils.BuildURL(malURL, "people", id, "a", "news"), "#content table tr td")
if err != nil {
return nil, code, err
}
return p.people.GetNews(doc), http.StatusOK, nil
}
// GetPeopleArticle to get people featured article list.
func (p *Parser) GetPeopleArticle(id int) ([]model.ArticleItem, int, error) {
doc, code, err := p.getDoc(utils.BuildURL(malURL, "people", id, "a", "featured"), ".news-list")
if err != nil {
return nil, code, err
}
return p.people.GetArticle(doc), http.StatusOK, nil
}
// GetPeoplePicture to get people picture list.
func (p *Parser) GetPeoplePicture(id int) ([]string, int, error) {
doc, code, err := p.getDoc(utils.BuildURL(malURL, "people", id, "a", "pictures"), "#content table tr td")
if err != nil {
return nil, code, err
}
return p.people.GetPictures(doc), http.StatusOK, nil
}