Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove and add items to library #122

Open
mkb79 opened this issue Sep 7, 2022 · 5 comments
Open

Remove and add items to library #122

mkb79 opened this issue Sep 7, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@mkb79
Copy link
Owner

mkb79 commented Sep 7, 2022

Hmm iis there any command to clean all library at once?

Also, how can i add a book to library using audible cli and asin?

(im not good using apis)

Originally posted by @tdguchi in #118 (comment)

@mkb79 mkb79 added the enhancement New feature or request label Sep 7, 2022
@johnlescault
Copy link

There is no command for this yet. But you can use the API with audible api -m put -b '{"asin": "ASIN_TO_ADD"}' -i 4 library/item

I'm sure this is a me issue. I made a script following what you said above (also figured this git would be better for this comment):

readarray -t asin < asin.txt;

for a in "${asin[@]}"
do  
    echo $a;
    audible api -m put -b '{"asin": $a}' -i 4 library/item
done;

asin.txt contains all the asin I would like to auto-add. My script returns the following:

$ bash audible_add_to_library.sh 
887558828
Uncaught Exception
Traceback (most recent call last):
  File "/home/joey/audible-test8/lib/python3.8/site-packages/audible_cli/cli.py", line 60, in main
    sys.exit(cli(*args, **kwargs))
  File "/home/joey/audible-test8/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/joey/audible-test8/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/joey/audible-test8/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/joey/audible-test8/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/joey/audible-test8/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/joey/audible-test8/lib/python3.8/site-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/joey/audible-test8/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/joey/audible-test8/lib/python3.8/site-packages/audible_cli/cmds/cmd_api.py", line 82, in cli
    body = json.loads(body)
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 10 (char 9)

Just hoping I can have some help here.

@johnlescault
Copy link

Solved my own issue. Had to do with the single quotes. Here is how I solved it

readarray -t asin < asin.txt;

for a in "${asin[@]}"
do  
    a='{"asin": "'"$a"'"}'
    echo $a;
    audible api -m put -b "$a" -i 4 library/item
done;

@mkb79
Copy link
Owner Author

mkb79 commented Sep 21, 2022

@johnlescault
Thank you for writing the script. I'll work now on an implementation for adding and removing books. It will look similar to the wishlist command.

@tdguchi
Copy link

tdguchi commented Oct 1, 2022

It could be useful to implement a subfunction to detect which asins are downloaded and flag them, so if you delete the .aaxc chapters or covers from the folder it doesnt download again (for large library and small disk space) unless you add another flag to force re-download

@mkb79
Copy link
Owner Author

mkb79 commented Oct 1, 2022

You can provide a --start-date and --end-date for this. So you can initially use audible download ... --all --end-date 2022-10-1 after that successfully download of all items you can remove them and next time you run audible download ... --all --start-date 2022-10-1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants