Fix bugs with own struct

This commit is contained in:
daru
2022-04-16 18:38:44 +02:00
parent ffc7d5624d
commit b021e418e9
3 changed files with 23 additions and 23 deletions

View File

@@ -46,26 +46,26 @@ func JikanConvert(jik *SeasonAnimeJikan) AnimeDetail {
return res return res
} }
func GetSeasonCache() (*SeasonJikan, error) { func GetSeasonCache() ([]Anime, error) {
data, err := cache.Get(seasonApiJikan) data, err := cache.Get(seasonApiJikan)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var seasonData SeasonJikan var seasonData []Anime
err = json.Unmarshal(data, &seasonData) err = json.Unmarshal(data, &seasonData)
return &seasonData, err return seasonData, err
} }
func SearchSeason(animeId int64) (*SeasonAnimeJikan, error) { func SearchSeason(animeId int64) (*Anime, error) {
season, err := GetSeasonCache() season, err := GetSeasonCache()
if err != nil { if err != nil {
return nil, err return nil, err
} }
if season.Pagination.Items.Count == 0 { if len(season) == 0 {
return nil, errors.New("no seasonal anime") return nil, errors.New("no seasonal anime")
} }
for _, a := range season.Data { for _, a := range season {
if a.MalID == animeId { if a.Anime == animeId {
return &a, err return &a, err
} }
} }

View File

@@ -1,5 +1,5 @@
{% package main %} {% package main %}
{% func Index(season *SeasonJikan) %} {% func Index(animes []Anime) %}
{% collapsespace %} {% collapsespace %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
@@ -23,16 +23,16 @@ body { background-color: #1a1a1a; color: #fff; }
<table> <table>
<tr> <tr>
<td><strong>Airing 📺</strong></td> <td><strong>Airing 📺</strong></td>
<td>{%d season.Pagination.Items.Total %}</td> <td>{%d len(animes) %}</td>
</tr> </tr>
</table> </table>
</br> </br>
<table> <table>
{% for _, anime := range season.Data %} {% for _, anime := range animes %}
<tr> <tr>
<td><strong>{%s anime.Title %}</strong></td> <td><strong>{%s anime.Data.Title %}</strong></td>
<td>{%dl anime.MalID %}</td> <td>{%dl anime.Anime %}</td>
<td>{%s anime.Aired.String %}</td> <td>{%d anime.Data.Episodes %}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>

View File

@@ -18,30 +18,30 @@ var (
) )
//line season.qtpl:2 //line season.qtpl:2
func StreamIndex(qw422016 *qt422016.Writer, season *SeasonJikan) { func StreamIndex(qw422016 *qt422016.Writer, animes []Anime) {
//line season.qtpl:2 //line season.qtpl:2
qw422016.N().S(` qw422016.N().S(`
`) `)
//line season.qtpl:3 //line season.qtpl:3
qw422016.N().S(` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> * { font-family: sans-serif; } table { border-spacing: 0; } td, th { text-align: left; padding: 0 0.5em; } td:first-child, th:first-child { padding-left: 0; } td:last-child, th:first-child { padding-right: 0; } body { background-color: #1a1a1a; color: #fff; } </style> <title>HUSO - Hanami universeller Serien Organizer</title> </head> <body> <h1>HUSO - Hanami universeller Serien Organizer</h1> <h2>Anime</h2> <table> <tr> <td><strong>Airing 📺</strong></td> <td>`) qw422016.N().S(` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> * { font-family: sans-serif; } table { border-spacing: 0; } td, th { text-align: left; padding: 0 0.5em; } td:first-child, th:first-child { padding-left: 0; } td:last-child, th:first-child { padding-right: 0; } body { background-color: #1a1a1a; color: #fff; } </style> <title>HUSO - Hanami universeller Serien Organizer</title> </head> <body> <h1>HUSO - Hanami universeller Serien Organizer</h1> <h2>Anime</h2> <table> <tr> <td><strong>Airing 📺</strong></td> <td>`)
//line season.qtpl:26 //line season.qtpl:26
qw422016.N().D(season.Pagination.Items.Total) qw422016.N().D(len(animes))
//line season.qtpl:26 //line season.qtpl:26
qw422016.N().S(`</td> </tr> </table> </br> <table> `) qw422016.N().S(`</td> </tr> </table> </br> <table> `)
//line season.qtpl:31 //line season.qtpl:31
for _, anime := range season.Data { for _, anime := range animes {
//line season.qtpl:31 //line season.qtpl:31
qw422016.N().S(` <tr> <td><strong>`) qw422016.N().S(` <tr> <td><strong>`)
//line season.qtpl:33 //line season.qtpl:33
qw422016.E().S(anime.Title) qw422016.E().S(anime.Data.Title)
//line season.qtpl:33 //line season.qtpl:33
qw422016.N().S(`</strong></td> <td>`) qw422016.N().S(`</strong></td> <td>`)
//line season.qtpl:34 //line season.qtpl:34
qw422016.N().DL(anime.MalID) qw422016.N().DL(anime.Anime)
//line season.qtpl:34 //line season.qtpl:34
qw422016.N().S(`</td> <td>`) qw422016.N().S(`</td> <td>`)
//line season.qtpl:35 //line season.qtpl:35
qw422016.E().S(anime.Aired.String) qw422016.N().D(anime.Data.Episodes)
//line season.qtpl:35 //line season.qtpl:35
qw422016.N().S(`</td> </tr> `) qw422016.N().S(`</td> </tr> `)
//line season.qtpl:37 //line season.qtpl:37
@@ -55,22 +55,22 @@ func StreamIndex(qw422016 *qt422016.Writer, season *SeasonJikan) {
} }
//line season.qtpl:42 //line season.qtpl:42
func WriteIndex(qq422016 qtio422016.Writer, season *SeasonJikan) { func WriteIndex(qq422016 qtio422016.Writer, animes []Anime) {
//line season.qtpl:42 //line season.qtpl:42
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line season.qtpl:42 //line season.qtpl:42
StreamIndex(qw422016, season) StreamIndex(qw422016, animes)
//line season.qtpl:42 //line season.qtpl:42
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line season.qtpl:42 //line season.qtpl:42
} }
//line season.qtpl:42 //line season.qtpl:42
func Index(season *SeasonJikan) string { func Index(animes []Anime) string {
//line season.qtpl:42 //line season.qtpl:42
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line season.qtpl:42 //line season.qtpl:42
WriteIndex(qb422016, season) WriteIndex(qb422016, animes)
//line season.qtpl:42 //line season.qtpl:42
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line season.qtpl:42 //line season.qtpl:42