Delete user from anime on finish

This commit is contained in:
daru
2022-05-18 21:05:37 +02:00
parent 1ae85f9110
commit be1419bfa7
4 changed files with 51 additions and 35 deletions

53
ober.go
View File

@@ -91,21 +91,16 @@ func AnimeGet(ctx *fasthttp.RequestCtx) {
ctx.SetStatusCode(fasthttp.StatusBadRequest)
return
}
// search season first
anime, err := SearchSeason(malId)
var bytes []byte
// search anime
anime, err := SearchAnime(malId)
if err != nil {
_, bytes, err = GetAnimeDetailData(malId)
if err != nil {
addErrorToCtx(ctx, err)
return
}
} else {
bytes, err = json.Marshal(&anime)
if err != nil {
addErrorToCtx(ctx, err)
return
}
addErrorToCtx(ctx, err)
return
}
bytes, err := json.Marshal(&anime)
if err != nil {
addErrorToCtx(ctx, err)
return
}
_, err = ctx.Write(bytes)
if err != nil {
@@ -123,8 +118,8 @@ func AnimeSearchGet(ctx *fasthttp.RequestCtx) {
return
}
query := string(ctx.QueryArgs().Peek("q"))
// Search with query
_, bytes, err := SearchAnime(query)
// search with query
_, bytes, err := SearchAnimeData(query)
if err != nil {
addErrorToCtx(ctx, err)
return
@@ -271,15 +266,11 @@ func WatchExtendedGet(ctx *fasthttp.RequestCtx) {
animeUsersExtended := make([]AnimeUserExtended, 0)
// make list advanced
for _, a := range animeUsers {
// Search season first
var data *Anime
data, err := SearchSeason(a.Anime)
// search anime
data, err := SearchAnime(a.Anime)
if err != nil {
data, _, err = GetAnimeDetailData(a.Anime)
if err != nil {
addErrorToCtx(ctx, err)
return
}
addErrorToCtx(ctx, err)
return
}
animeUsersExtended = append(animeUsersExtended, AnimeUserExtended{
Anime: a.Anime,
@@ -545,16 +536,12 @@ func processUpdateReq(ctx *fasthttp.RequestCtx, update bool) {
// iterate sent animes
for i, anime := range animes {
// check if anime is in season
_, err = SearchSeason(anime.Anime)
// anime holen sie diese
_, err = SearchAnime(anime.Anime)
if err != nil {
// anime not in season => holen sie diese
_, _, err := GetAnimeDetailData(anime.Anime)
if err != nil {
ctx.WriteString(err.Error())
ctx.SetStatusCode(fasthttp.StatusNotFound)
return
}
ctx.WriteString(err.Error())
ctx.SetStatusCode(fasthttp.StatusNotFound)
return
}
var animeData *AnimeUser