Improved company import
This commit is contained in:
parent
a8c5cafa4e
commit
3147477a44
@ -227,5 +227,20 @@ component AnimeInformation(anime *arn.Anime)
|
||||
td.anime-info-value
|
||||
a.ajax(href=company.Link())= company.Name.English
|
||||
|
||||
//- section.anime-section.mountable
|
||||
//- h3.anime-section-name Companies
|
||||
//- table.anime-info-table
|
||||
//- each company in anime.Producers()
|
||||
//- tr.mountable(data-mountable-type="info")
|
||||
//- td.anime-info-key Producer:
|
||||
//- td.anime-info-value
|
||||
//- a.ajax(href=company.Link())= company.Name.English
|
||||
|
||||
//- each company in anime.Licensors()
|
||||
//- tr.mountable(data-mountable-type="info")
|
||||
//- td.anime-info-key Licensor:
|
||||
//- td.anime-info-value
|
||||
//- a.ajax(href=company.Link())= company.Name.English
|
||||
|
||||
component FriendEntry(friend *arn.User, listItems map[*arn.User]*arn.AnimeListItem)
|
||||
CustomAvatar(friend, listItems[friend].Link(friend.Nick), friend.Nick + " => " + listItems[friend].Status + " | " + toString(listItems[friend].Episodes) + " eps | " + fmt.Sprintf("%.1f", listItems[friend].Rating.Overall) + " rating")
|
||||
|
@ -34,7 +34,6 @@ func main() {
|
||||
}
|
||||
|
||||
color.Green("Finished importing %d companies", len(companies))
|
||||
time.Sleep(2 * time.Second)
|
||||
}
|
||||
|
||||
func importCompanies(anime *arn.Anime, malID string) {
|
||||
@ -47,8 +46,28 @@ func importCompanies(anime *arn.Anime, malID string) {
|
||||
|
||||
jikanAnime := obj.(*jikan.Anime)
|
||||
|
||||
for _, studioInfo := range jikanAnime.Studio {
|
||||
studioName := studioInfo[1]
|
||||
for _, info := range jikanAnime.Studio {
|
||||
importByName(anime, "studio", info)
|
||||
}
|
||||
|
||||
for _, info := range jikanAnime.Producer {
|
||||
importByName(anime, "producer", info)
|
||||
}
|
||||
|
||||
for _, info := range jikanAnime.Licensor {
|
||||
importByName(anime, "licensor", info)
|
||||
}
|
||||
}
|
||||
|
||||
func importByName(anime *arn.Anime, companyType string, info []string) {
|
||||
studioMALID := info[0]
|
||||
slashPos := strings.Index(studioMALID, "/")
|
||||
|
||||
if slashPos != -1 {
|
||||
studioMALID = studioMALID[:slashPos]
|
||||
}
|
||||
|
||||
studioName := info[1]
|
||||
htmlPos := strings.Index(studioName, "<")
|
||||
|
||||
if htmlPos != -1 {
|
||||
@ -67,7 +86,14 @@ func importCompanies(anime *arn.Anime, malID string) {
|
||||
},
|
||||
Created: now.UTC().Format(time.RFC3339),
|
||||
CreatedBy: "",
|
||||
Mappings: []*arn.Mapping{},
|
||||
Mappings: []*arn.Mapping{
|
||||
&arn.Mapping{
|
||||
Service: "myanimelist/producer",
|
||||
ServiceID: studioMALID,
|
||||
Created: arn.DateTimeUTC(),
|
||||
CreatedBy: "",
|
||||
},
|
||||
},
|
||||
Links: []*arn.Link{},
|
||||
Tags: []string{},
|
||||
Likes: []string{},
|
||||
@ -76,7 +102,14 @@ func importCompanies(anime *arn.Anime, malID string) {
|
||||
companies[studioName] = company
|
||||
}
|
||||
|
||||
switch companyType {
|
||||
case "studio":
|
||||
anime.StudioIDs = append(anime.StudioIDs, company.ID)
|
||||
case "producer":
|
||||
anime.ProducerIDs = append(anime.ProducerIDs, company.ID)
|
||||
case "licensor":
|
||||
anime.LicensorIDs = append(anime.LicensorIDs, company.ID)
|
||||
}
|
||||
|
||||
anime.Save()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user