diff --git a/go.mod b/go.mod
index e0a9048..1411059 100644
--- a/go.mod
+++ b/go.mod
@@ -16,7 +16,7 @@ require (
require (
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/bwmarrin/snowflake v0.3.0 // indirect
- github.com/klauspost/compress v1.15.6 // indirect
+ github.com/klauspost/compress v1.15.7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/savsgio/gotils v0.0.0-20220530130905-52f3993e8d6d // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
diff --git a/go.sum b/go.sum
index 4f14043..d222c3b 100644
--- a/go.sum
+++ b/go.sum
@@ -20,8 +20,8 @@ github.com/gookit/color v1.5.1/go.mod h1:wZFzea4X8qN6vHOSP2apMb4/+w/orMznEzYsIHP
github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
github.com/klauspost/compress v1.13.5/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
-github.com/klauspost/compress v1.15.6 h1:6D9PcO8QWu0JyaQ2zUMmu16T1T+zjjEpP91guRsvDfY=
-github.com/klauspost/compress v1.15.6/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
+github.com/klauspost/compress v1.15.7 h1:7cgTQxJCU/vy+oP/E3B9RGbQTgbiVzIJWIKOLoAsPok=
+github.com/klauspost/compress v1.15.7/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
diff --git a/klotz.go b/klotz.go
index 272dcb6..c726630 100644
--- a/klotz.go
+++ b/klotz.go
@@ -317,3 +317,10 @@ type MmOracle struct {
Anime int64 `json:"anime"`
AvgScore int `json:"avgScore"`
}
+
+type MovieChart struct {
+ MmId int `json:"mmId"`
+ AvgScore float64 `json:"avgScore"`
+ UserCount int `json:"userCount"`
+ Data Anime `json:"data"`
+}
diff --git a/ober.go b/ober.go
index 39679d9..d79134a 100644
--- a/ober.go
+++ b/ober.go
@@ -9,6 +9,7 @@ import (
"time"
"github.com/fasthttp/router"
+ "github.com/gookit/color"
"github.com/valyala/fasthttp"
"github.com/xujiajun/nutsdb"
)
@@ -46,11 +47,15 @@ func Start(ctx *fasthttp.RequestCtx) {
oracles, err := MmReadOracle()
if err != nil {
- addErrorToCtx(ctx, err)
- return
+ color.Errorln(err.Error())
}
- WriteIndex(ctx, season, oracles, logOut.String())
+ charts, err := BuildMovieCharts()
+ if err != nil {
+ color.Errorln(err.Error())
+ }
+
+ WriteIndex(ctx, season, oracles, charts, logOut.String())
ctx.SetContentType("text/html; charset=utf-8")
ctx.SetStatusCode(fasthttp.StatusOK)
diff --git a/praktikant.go b/praktikant.go
index b473bf9..fedcca4 100644
--- a/praktikant.go
+++ b/praktikant.go
@@ -194,6 +194,27 @@ func LangeArbeit() {
}
}
+ charts, err := BuildMovieCharts()
+ if err != nil {
+ color.Errorln(err.Error())
+ logOut.WriteError(err)
+ } else {
+ for _, c := range charts {
+ // search season first
+ _, err = SearchSeason(c.Data.Anime)
+ if err == nil {
+ continue
+ }
+ err = refreshAnime(c.Data.Anime)
+ if err != nil {
+ color.Errorln(err.Error())
+ logOut.WriteError(err)
+ continue
+ }
+ count++
+ }
+ }
+
color.Infof("%d Anime aktualisiert\n", count)
logOut.WriteLine(fmt.Sprintf("🔃 %d Anime aktualisiert", count))
}
diff --git a/schaffer.go b/schaffer.go
index 2e39550..a451146 100644
--- a/schaffer.go
+++ b/schaffer.go
@@ -7,6 +7,7 @@ import (
"strings"
"time"
+ "github.com/gookit/color"
"github.com/xujiajun/nutsdb"
)
@@ -270,3 +271,40 @@ func CheckAnimeExistInDbAndUserWatches(animeId, userId int64) (bool, error) {
}
return false, err
}
+
+func BuildMovieCharts() ([]MovieChart, error) {
+ key := "charts"
+ var charts []MovieChart
+ data, err := mmCache.Get(key)
+ if err == nil {
+ err = json.Unmarshal(data, &charts)
+ if err == nil {
+ return charts, err
+ }
+ }
+
+ movieList, err := MmReadCharts()
+ if err != nil {
+ return nil, err
+ }
+ charts = make([]MovieChart, 0)
+ for _, m := range movieList {
+ c := MovieChart{
+ MmId: m.Id,
+ }
+ anime, err := SearchAnime(m.Anime)
+ if err != nil {
+ color.Errorln(err.Error())
+ } else {
+ c.Data = *anime
+ charts = append(charts, c)
+ }
+ }
+
+ bytes, err := json.Marshal(charts)
+ if err == nil {
+ mmCache.Set(key, bytes)
+ }
+
+ return charts, nil
+}
diff --git a/season.qtpl b/season.qtpl
index e649b8b..ceefbec 100644
--- a/season.qtpl
+++ b/season.qtpl
@@ -1,5 +1,5 @@
{% package main %}
-{% func Index(animes []Anime, oracles []MmOracle, log string) %}
+{% func Index(animes []Anime, oracles []MmOracle, charts []MovieChart, log string) %}
{% collapsespace %}
@@ -30,23 +30,52 @@ body { background-color: #1a1a1a; color: #fff; }
+
+ | MALID |
+ SCORE |
+ TITLE |
+
{% for _, anime := range animes %}
| {%dl anime.Anime %} |
- {%s anime.Title %} |
- {%d anime.Episodes %} |
{%f anime.Score %} |
+ {%s anime.Title %} |
+
+ {% endfor %}
+
+ MovieManager Charts
+
+
+ | MMID |
+ MALID |
+ USER |
+ SCORE |
+ TITLE |
+
+ {% for _, chart := range charts %}
+
+ | {%d chart.MmId %} |
+ {%dl chart.Data.Anime %} |
+ {%d chart.UserCount %} |
+ {%f chart.AvgScore %} |
+ {%s chart.Data.Title %} |
{% endfor %}
MovieManager Oracle
+
+ | MMID |
+ MALID |
+ SCORE |
+ TITLE |
+
{% for _, oracle := range oracles %}
| {%d oracle.Id %} |
+ {%dl oracle.Anime %} |
{%d oracle.AvgScore %} |
{%s oracle.Title %} |
- {%dl oracle.Anime %} |
{% endfor %}
diff --git a/season.qtpl.go b/season.qtpl.go
index 50600b4..c3bd21d 100644
--- a/season.qtpl.go
+++ b/season.qtpl.go
@@ -18,7 +18,7 @@ var (
)
//line season.qtpl:2
-func StreamIndex(qw422016 *qt422016.Writer, animes []Anime, oracles []MmOracle, log string) {
+func StreamIndex(qw422016 *qt422016.Writer, animes []Anime, oracles []MmOracle, charts []MovieChart, log string) {
//line season.qtpl:2
qw422016.N().S(`
`)
@@ -31,91 +31,123 @@ func StreamIndex(qw422016 *qt422016.Writer, animes []Anime, oracles []MmOracle,
//line season.qtpl:28
qw422016.N().D(len(animes))
//line season.qtpl:28
- qw422016.N().S(` `)
-//line season.qtpl:33
+ qw422016.N().S(`
| MALID | SCORE | TITLE |
`)
+//line season.qtpl:38
for _, anime := range animes {
-//line season.qtpl:33
+//line season.qtpl:38
qw422016.N().S(` | `)
-//line season.qtpl:35
+//line season.qtpl:40
qw422016.N().DL(anime.Anime)
-//line season.qtpl:35
- qw422016.N().S(` | `)
-//line season.qtpl:36
- qw422016.E().S(anime.Title)
-//line season.qtpl:36
- qw422016.N().S(` | `)
-//line season.qtpl:37
- qw422016.N().D(anime.Episodes)
-//line season.qtpl:37
- qw422016.N().S(` | `)
-//line season.qtpl:38
- qw422016.N().F(anime.Score)
-//line season.qtpl:38
- qw422016.N().S(` |
`)
//line season.qtpl:40
- }
-//line season.qtpl:40
- qw422016.N().S(`
MovieManager Oracle
`)
-//line season.qtpl:44
- for _, oracle := range oracles {
-//line season.qtpl:44
- qw422016.N().S(` | `)
-//line season.qtpl:46
- qw422016.N().D(oracle.Id)
-//line season.qtpl:46
qw422016.N().S(` | `)
-//line season.qtpl:47
- qw422016.N().D(oracle.AvgScore)
-//line season.qtpl:47
+//line season.qtpl:41
+ qw422016.N().F(anime.Score)
+//line season.qtpl:41
qw422016.N().S(` | `)
-//line season.qtpl:48
- qw422016.E().S(oracle.Title)
-//line season.qtpl:48
- qw422016.N().S(` | `)
-//line season.qtpl:49
- qw422016.N().DL(oracle.Anime)
-//line season.qtpl:49
- qw422016.N().S(` |
`)
-//line season.qtpl:51
+//line season.qtpl:42
+ qw422016.E().S(anime.Title)
+//line season.qtpl:42
+ qw422016.N().S(` `)
+//line season.qtpl:44
}
-//line season.qtpl:51
- qw422016.N().S(`