Compare commits
4 Commits
1.5.0
..
b6bdee4df6
| Author | SHA1 | Date | |
|---|---|---|---|
| b6bdee4df6 | |||
| cbda217d18 | |||
| ceb756a1a8 | |||
| 3621b66437 |
@@ -36,3 +36,4 @@ http-client.private.env.json
|
||||
|
||||
# Build artifacts
|
||||
build/*.tar.gz
|
||||
AniTrack
|
||||
|
||||
@@ -11,6 +11,21 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Unmarshalling accidental numbers received from MAL to strings
|
||||
func (f *FlexString) UnmarshalJSON(data []byte) error {
|
||||
var s string
|
||||
if err := json.Unmarshal(data, &s); err == nil {
|
||||
*f = FlexString(s)
|
||||
return nil
|
||||
}
|
||||
var n json.Number
|
||||
if err := json.Unmarshal(data, &n); err == nil {
|
||||
*f = FlexString(string(n))
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("FlexString: invalid value")
|
||||
}
|
||||
|
||||
func MALHelper(method string, malUrl string, body url.Values) (json.RawMessage, string, error) {
|
||||
client := &http.Client{}
|
||||
|
||||
|
||||
+10
-6
@@ -1,6 +1,10 @@
|
||||
package main
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type FlexString string
|
||||
|
||||
type MyAnimeListJWT struct {
|
||||
TokenType string `json:"token_type"`
|
||||
@@ -129,11 +133,11 @@ type MALAnime struct {
|
||||
Statistics struct {
|
||||
NumListUsers int `json:"num_list_users" ts_type:"numListUsers"`
|
||||
Status struct {
|
||||
Watching string `json:"watching" ts_type:"watching"`
|
||||
Completed string `json:"completed" ts_type:"completed"`
|
||||
OnHold string `json:"on_hold" ts_type:"onHold"`
|
||||
Dropped string `json:"dropped" ts_type:"dropped"`
|
||||
PlanToWatch string `json:"plan_to_watch" ts_type:"planToWatch"`
|
||||
Watching FlexString `json:"watching" ts_type:"string"`
|
||||
Completed FlexString `json:"completed" ts_type:"string"`
|
||||
OnHold FlexString `json:"on_hold" ts_type:"string"`
|
||||
Dropped FlexString `json:"dropped" ts_type:"string"`
|
||||
PlanToWatch FlexString `json:"plan_to_watch" ts_type:"string"`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,8 +230,7 @@ export namespace main {
|
||||
background: background;
|
||||
related_anime: relatedAnime;
|
||||
recommendations: recommendations;
|
||||
// Go type: struct { NumListUsers int "json:\"num_list_users\" ts_type:\"numListUsers\""; Status struct { Watching string "json:\"watching\" ts_type:\"watching\""; Completed string "json:\"completed\" ts_type:\"completed\""; OnHold string "json:\"on_hold\" ts_type:\"onHold\""; Dropped string "json:\"dropped\" ts_type:\"dropped\""; PlanToWatch string "json:\"plan_to_watch\" ts_type:\"planToWatch\"" } }
|
||||
Statistics: any;
|
||||
Statistics: struct { NumListUsers int "json:\"num_list_users\" ts_type:\"numListUsers\""; Status struct { Watching main.;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new MALAnime(source);
|
||||
@@ -624,6 +623,43 @@ export namespace struct { Node struct { Id int "json:\"id\" ts_type:\"id\""; Tit
|
||||
|
||||
}
|
||||
|
||||
export namespace struct { NumListUsers int "json:\"num_list_users\" ts_type:\"numListUsers\""; Status struct { Watching main {
|
||||
|
||||
export class {
|
||||
num_list_users: numListUsers;
|
||||
Status: struct { Watching main.;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new (source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.num_list_users = source["num_list_users"];
|
||||
this.Status = this.convertValues(source["Status"], Object);
|
||||
}
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
if (a.slice && a.map) {
|
||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||
} else if ("object" === typeof a) {
|
||||
if (asMap) {
|
||||
for (const key of Object.keys(a)) {
|
||||
a[key] = new classs(a[key]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return new classs(a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export namespace struct { Status string "json:\"status\" ts_type:\"status\""; Score int "json:\"score\" ts_type:\"score\""; NumEpisodesWatched int "json:\"num_episodes_watched\" ts_type:\"numEpisodesWatched\""; IsRewatching bool "json:\"is_rewatching\" ts_type:\"isRewatching\""; UpdatedAt time {
|
||||
|
||||
export class {
|
||||
@@ -653,3 +689,28 @@ export namespace struct { Status string "json:\"status\" ts_type:\"status\""; Sc
|
||||
|
||||
}
|
||||
|
||||
export namespace struct { Watching main {
|
||||
|
||||
export class {
|
||||
watching: string;
|
||||
completed: string;
|
||||
on_hold: string;
|
||||
dropped: string;
|
||||
plan_to_watch: string;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new (source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.watching = source["watching"];
|
||||
this.completed = source["completed"];
|
||||
this.on_hold = source["on_hold"];
|
||||
this.dropped = source["dropped"];
|
||||
this.plan_to_watch = source["plan_to_watch"];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -12,6 +12,6 @@
|
||||
},
|
||||
"info": {
|
||||
"productName": "AniTrack",
|
||||
"productVersion": "1.5.0"
|
||||
"productVersion": "1.5.1"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user