diff options
| author | Paul Buetow <paul@buetow.org> | 2025-07-18 14:48:09 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-07-18 14:48:09 +0300 |
| commit | cdae50a5fec59f4715a58316188f87bcafdf2612 (patch) | |
| tree | f524e63ffdcc92a7e82fe049f404263c0cef3281 /internal | |
| parent | a6e9947b904406ec5b49e88c77689d5c6ef6d04b (diff) | |
fix: Anki import error - add missing fields to deck config
- Added missing 'id' field to deck configuration (dconf)
- Added required fields to deck options: perDay, order, leechFails, etc.
- Added missing fields to note type: sortf, req, vers
- Fixed req field format to use interface{} for mixed types
- Removed duplicate 'did' field in note type config
- Added 'dyn', 'conf', and 'usn' fields to deck definitions
This fixes the '500: JsonError missing field id' error when importing APKG files into Anki desktop.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/anki/apkg_generator.go | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/internal/anki/apkg_generator.go b/internal/anki/apkg_generator.go index 5c5c25d..25f8743 100644 --- a/internal/anki/apkg_generator.go +++ b/internal/anki/apkg_generator.go @@ -201,6 +201,9 @@ func (g *APKGGenerator) insertCollection(db *sql.DB) error { "mod": now, "desc": "", "collapsed": false, + "dyn": 0, + "conf": 1, + "usn": 0, }, fmt.Sprintf("%d", g.deckID): map[string]interface{}{ "id": g.deckID, @@ -208,6 +211,9 @@ func (g *APKGGenerator) insertCollection(db *sql.DB) error { "mod": now, "desc": "Bulgarian vocabulary cards created by TotalRecall", "collapsed": false, + "dyn": 0, + "conf": 1, + "usn": 0, }, } decksJSON, _ := json.Marshal(decks) @@ -235,20 +241,32 @@ func (g *APKGGenerator) insertCollection(db *sql.DB) error { // Deck options dconf := map[string]interface{}{ "1": map[string]interface{}{ + "id": 1, "name": "Default", "new": map[string]interface{}{ "delays": []int{1, 10}, "ints": []int{1, 4, 7}, "initialFactor": 2500, + "perDay": 20, + "order": 1, }, "lapse": map[string]interface{}{ "delays": []int{10}, "mult": 0, "minInt": 1, + "leechFails": 8, + "leechAction": 0, }, "rev": map[string]interface{}{ + "perDay": 100, + "ease4": 1.3, + "fuzz": 0.05, "maxIvl": 36500, }, + "timer": 0, + "maxTaken": 60, + "usn": 0, + "mod": now, }, } dconfJSON, _ := json.Marshal(dconf) @@ -280,6 +298,10 @@ func (g *APKGGenerator) createNoteTypeConfig() map[string]interface{} { "type": 0, "mod": time.Now().Unix(), "usn": -1, + "sortf": 0, + "did": g.deckID, + "req": [][]interface{}{[]interface{}{0, "all", []int{0}}}, + "vers": []int{}, "flds": []map[string]interface{}{ { "name": "English", @@ -331,7 +353,6 @@ func (g *APKGGenerator) createNoteTypeConfig() map[string]interface{} { }, }, "css": g.getCSS(), - "did": g.deckID, } } |
