mak-alex / litres-backup

litres-backup- Assistant for backing up your books from a book resource litres.ru
14 stars 1 forks source link

Error with API Request #2

Closed crrlcx closed 3 years ago

crrlcx commented 3 years ago

Valid username and password, but invalid API response

Command litres-backup book -a -v Result

FATAL   cobra@v1.1.3/command.go:856     [litres.GetBooks]       {"error": "expected element type <catalit-fb2-books> but have <catalit-bad-request>"}
crrlcx commented 3 years ago

I just built the backlitr from tags/v1.0.0. I successfully gets a list of books with this version.

backlitr book -a -v          
Display a list of available books for download:
        0. Элиезер Юдковский - Гарри Поттер и методы рационального мышления
        1. Максим Дорофеев - Путь джедая
        2. Харуки Мураками - Токийские легенды (сборник)
crrlcx commented 3 years ago

Look a like that You should switch to JSON instead XML More about Litres JSON API

crrlcx commented 3 years ago

How to reproduce:

$ docker run --rm -it -v ${PWD}/.litres-backup:/data golang:1.16
root@3f9b8c5e39ea:/go# env
HOSTNAME=3f9b8c5e39ea
PWD=/go
HOME=/root
GOLANG_VERSION=1.16.3
TERM=xterm
SHLVL=1
PATH=/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
GOPATH=/go
_=/usr/bin/env
root@3f9b8c5e39ea:/go# git clone https://github.com/mak-alex/litres-backup.git $GOPATH/src/github.com/mak-alex/litres-backup
Cloning into '/go/src/github.com/mak-alex/litres-backup'...
remote: Enumerating objects: 191, done.
remote: Counting objects: 100% (191/191), done.
remote: Compressing objects: 100% (112/112), done.
remote: Total 191 (delta 84), reused 156 (delta 55), pack-reused 0
Receiving objects: 100% (191/191), 57.27 KiB | 792.00 KiB/s, done.
Resolving deltas: 100% (84/84), done.
root@3f9b8c5e39ea:/go# cd $GOPATH/src/github.com/mak-alex/litres-backup
root@3f9b8c5e39ea:/go/src/github.com/mak-alex/litres-backup# go build
go: downloading go.uber.org/zap v1.10.0
go: downloading github.com/spf13/viper v1.7.0
go: downloading github.com/spf13/cobra v1.1.3
go: downloading github.com/mattn/go-colorable v0.1.6
go: downloading gopkg.in/natefinch/lumberjack.v2 v2.0.0
go: downloading github.com/pelletier/go-toml v1.8.1
go: downloading github.com/pkg/errors v0.9.1
go: downloading go.uber.org/atomic v1.4.0
go: downloading go.uber.org/multierr v1.1.0
go: downloading github.com/cheggaaa/pb v1.0.29
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/mattn/go-isatty v0.0.12
go: downloading github.com/fsnotify/fsnotify v1.4.9
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading github.com/magiconair/properties v1.8.1
go: downloading github.com/mitchellh/mapstructure v1.4.1
go: downloading github.com/spf13/afero v1.1.2
go: downloading github.com/spf13/cast v1.3.0
go: downloading github.com/spf13/jwalterweatherman v1.0.0
go: downloading github.com/subosito/gotenv v1.2.0
go: downloading gopkg.in/ini.v1 v1.51.0
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading github.com/mattn/go-runewidth v0.0.4
go: downloading golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c
go: downloading golang.org/x/text v0.3.5
root@3f9b8c5e39ea:/go/src/github.com/mak-alex/litres-backup# ./litres-backup book -a -n -v -d --config /data/
config/ logs/
root@3f9b8c5e39ea:/go/src/github.com/mak-alex/litres-backup# ./litres-backup book -a -n -v -d --config /data/config/config.yaml
2021/04/04 20:45:15 200 OK
2021-04-04T20:45:15.316Z        FATAL   cobra@v1.1.3/command.go:856     [litres.GetBooks]       {"error": "expected element type <catalit-fb2-books> but have <catalit-bad-request>"}
root@3f9b8c5e39ea:/go/src/github.com/mak-alex/litres-backup#
mak-alex commented 3 years ago

Hi, thanks for the comment. I corrected the error.

mak-alex commented 3 years ago

Look a like that You should switch to JSON instead XML More about Litres JSON API

Yes, I am considering such a transition