mirror of
https://github.com/ultrasn0w/huso.git
synced 2025-12-14 08:39:53 +01:00
NextNextSeason
This commit is contained in:
58
knecht.go
58
knecht.go
@@ -135,45 +135,9 @@ func GetUserData(username string) (*User, []byte, error) {
|
||||
return &user, data, err
|
||||
}
|
||||
|
||||
func GetSeasonDataAll() ([]Anime, []byte, error) {
|
||||
seasonStr := GetCurrentSeasonString()
|
||||
color.Infoln("Aktuelle Season (" + seasonStr + ") abfragen...")
|
||||
logOut.WriteLine("📺 Aktuelle Season (" + seasonStr + ") abfragen...")
|
||||
data, _, err := GetSeasonData(seasonApiJikan, 1)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
color.Infof("%d Anime auf %d Seiten\n", data.Pagination.Items.Total, data.Pagination.LastVisiblePage)
|
||||
logOut.WriteLine(fmt.Sprintf("📺 %d Anime auf %d Seiten", data.Pagination.Items.Total, data.Pagination.LastVisiblePage))
|
||||
animes := make([]Anime, 0)
|
||||
// convert to anime
|
||||
for _, a := range data.Data {
|
||||
animes = append(animes, JikanConvert(&a))
|
||||
}
|
||||
for i := 2; data.Pagination.HasNextPage; i++ {
|
||||
color.Infof("Seite %d abfragen...\n", i)
|
||||
logOut.WriteLine(fmt.Sprintf("📺 Seite %d abfragen...", i))
|
||||
newData, _, err := GetSeasonData(seasonApiJikan, i)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
data.Pagination.CurrentPage = newData.Pagination.CurrentPage
|
||||
data.Pagination.HasNextPage = newData.Pagination.HasNextPage
|
||||
data.Pagination.Items.Count += newData.Pagination.Items.Count
|
||||
// convert to anime
|
||||
for _, a := range newData.Data {
|
||||
animes = append(animes, JikanConvert(&a))
|
||||
}
|
||||
}
|
||||
color.Infof("%d Anime bekommen\n", len(animes))
|
||||
logOut.WriteLine(fmt.Sprintf("📺 %d Anime bekommen", len(animes)))
|
||||
bytes, err := json.Marshal(animes)
|
||||
return animes, bytes, err
|
||||
}
|
||||
|
||||
func GetNextSeasonDataAll(season string) ([]Anime, []byte, error) {
|
||||
color.Infoln("Nächste Season (" + season + ") abfragen...")
|
||||
logOut.WriteLine("📺 Nächste Season (" + season + ") abfragen...")
|
||||
func GetSeasonDataAll(season string) ([]Anime, []byte, error) {
|
||||
color.Infoln("Season (" + season + ") abfragen...")
|
||||
logOut.WriteLine("📺 Season (" + season + ") abfragen...")
|
||||
data, _, err := GetSeasonData(seasonStrJikan+season, 1)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -294,3 +258,19 @@ func GetNextSeasonString() string {
|
||||
return fmt.Sprintf("%04d", now.Year())
|
||||
}
|
||||
}
|
||||
|
||||
func GetNextNextSeasonString() string {
|
||||
var now = time.Now()
|
||||
switch now.Month() {
|
||||
case time.January, time.February, time.March:
|
||||
return fmt.Sprintf("%04d/summer", now.Year())
|
||||
case time.April, time.May, time.June:
|
||||
return fmt.Sprintf("%04d/fall", now.Year())
|
||||
case time.July, time.August, time.September:
|
||||
return fmt.Sprintf("%04d/winter", now.Year()+1)
|
||||
case time.October, time.November, time.December:
|
||||
return fmt.Sprintf("%04d/spring", now.Year()+1)
|
||||
default:
|
||||
return fmt.Sprintf("%04d", now.Year())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user