Added stuff
This commit is contained in:
parent
cb06b74d17
commit
a53fff7391
58
main.go
58
main.go
@ -15,7 +15,7 @@ func main() {
|
|||||||
r := router.New()
|
r := router.New()
|
||||||
r.GET(`/`, home)
|
r.GET(`/`, home)
|
||||||
r.GET(`/compare/:user`, compare)
|
r.GET(`/compare/:user`, compare)
|
||||||
r.Start(`:8080`)
|
r.Start(`:8070`)
|
||||||
}
|
}
|
||||||
|
|
||||||
type jikanAPIUserList struct {
|
type jikanAPIUserList struct {
|
||||||
@ -31,7 +31,8 @@ type jikanAPIUserList struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type jikanAPIAnime struct {
|
type jikanAPIAnime struct {
|
||||||
MalID int `json:"mal_id"`
|
MeikanID int `json:"meikan_id"`
|
||||||
|
MyanimelistID int `json:"mal_id"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
ImageURL string `json:"image_url"`
|
ImageURL string `json:"image_url"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
@ -39,7 +40,25 @@ type jikanAPIAnime struct {
|
|||||||
Score int `json:"score"`
|
Score int `json:"score"`
|
||||||
WatchedEpisodes int `json:"watched_episodes"`
|
WatchedEpisodes int `json:"watched_episodes"`
|
||||||
TotalEpisodes int `json:"total_episodes"`
|
TotalEpisodes int `json:"total_episodes"`
|
||||||
MeikanID int `json:"meikan_id"`
|
AiringStatus int `json:"airing_status"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type meikanListItem struct {
|
||||||
|
Anime meikanAnime `json:"anime"`
|
||||||
|
State string `json:"state"`
|
||||||
|
Episode int `json:"episode"`
|
||||||
|
Rating int `json:"rating"`
|
||||||
|
Hidden bool `json:"hidden"`
|
||||||
|
Recommended bool `json:"recommend"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type meikanAnime struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Episodes int `json:"episodes"`
|
||||||
|
State string `json:"state"`
|
||||||
|
Rating string `json:"rating"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type meikanAPIIDs struct {
|
type meikanAPIIDs struct {
|
||||||
@ -63,27 +82,46 @@ func compare(c *router.Context) error {
|
|||||||
//https://api.jikan.moe/v3/user/nekomata1037/animelist/all
|
//https://api.jikan.moe/v3/user/nekomata1037/animelist/all
|
||||||
//https://api.meikan.moe/v1/ids/anime
|
//https://api.meikan.moe/v1/ids/anime
|
||||||
jikanList := jikanAPIGetUserAnimelist(user)
|
jikanList := jikanAPIGetUserAnimelist(user)
|
||||||
|
var anime []meikanListItem
|
||||||
//fmt.Println(result)
|
//fmt.Println(result)
|
||||||
IDs := meikanAPIGetIDs()
|
IDs := meikanAPIGetIDs()
|
||||||
for i := 0; i < len(jikanList.Anime); i++ {
|
for i := 0; i < len(jikanList.Anime); i++ {
|
||||||
//fmt.Println(result.Anime[i].Title)
|
//fmt.Println(result.Anime[i].Title)
|
||||||
for d := 0; d < len(IDs); d++ {
|
for d := 0; d < len(IDs); d++ {
|
||||||
if jikanList.Anime[i].MalID == IDs[d].MyanimelistID {
|
if jikanList.Anime[i].MyanimelistID == IDs[d].MyanimelistID {
|
||||||
jikanList.Anime[i].MeikanID = IDs[d].MeikanID
|
jikanList.Anime[i].MeikanID = IDs[d].MeikanID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if jikanList.Anime[i].WatchingStatus == 1 {
|
temp := meikanListItem{Anime: meikanAnime{ID: jikanList.Anime[i].MeikanID,
|
||||||
jikanList.Watching++
|
Title: jikanList.Anime[i].Title,
|
||||||
} else if jikanList.Anime[i].WatchingStatus == 2 {
|
Type: jikanList.Anime[i].Type,
|
||||||
|
Episodes: jikanList.Anime[i].TotalEpisodes},
|
||||||
|
Episode: jikanList.Anime[i].WatchedEpisodes,
|
||||||
|
Rating: jikanList.Anime[i].Score}
|
||||||
|
switch jikanList.Anime[i].WatchingStatus {
|
||||||
|
case 1:
|
||||||
jikanList.Completed++
|
jikanList.Completed++
|
||||||
} else if jikanList.Anime[i].WatchingStatus == 3 {
|
temp.State = "Watching"
|
||||||
|
case 2:
|
||||||
|
jikanList.Completed++
|
||||||
|
temp.State = "Finished"
|
||||||
|
case 3:
|
||||||
jikanList.OnHold++
|
jikanList.OnHold++
|
||||||
} else if jikanList.Anime[i].WatchingStatus == 4 {
|
temp.State = "On Hold"
|
||||||
|
case 4:
|
||||||
jikanList.Dropped++
|
jikanList.Dropped++
|
||||||
} else if jikanList.Anime[i].WatchingStatus == 6 {
|
temp.State = "Dropped"
|
||||||
|
case 6:
|
||||||
jikanList.PlanToWatch++
|
jikanList.PlanToWatch++
|
||||||
|
temp.State = "Plan to watch"
|
||||||
}
|
}
|
||||||
|
switch jikanList.Anime[i].AiringStatus {
|
||||||
|
case 2:
|
||||||
|
temp.Anime.State = "Finished"
|
||||||
|
}
|
||||||
|
anime = append(anime, temp)
|
||||||
}
|
}
|
||||||
|
//fmt.Println(anime)
|
||||||
//resJSON, err := json.MarshalIndent(result, "", "\t")
|
//resJSON, err := json.MarshalIndent(result, "", "\t")
|
||||||
//check(err)
|
//check(err)
|
||||||
//jsonfile := []byte(resJSON)
|
//jsonfile := []byte(resJSON)
|
||||||
|
Loading…
Reference in New Issue
Block a user