Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Support for: books.ch / orellfuessli.ch, meta data, cover #40

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
__pycache__
*.bak
venv/
.idea/
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ to allow scripted access to a few very basic commands:
- delete an ebook / upload
- list devices connected to an account
- unregister a device from an account
- update meta data
- update cover

Status
======
Expand All @@ -43,6 +45,7 @@ Works with these partners:
- Thalia.de (3)
- Thalia.at (4)
- Buch.de (6)
- books.ch / orellfuessli.ch (8)
- Hugendubel.de (13)
- Buecher.de (30)

Expand All @@ -55,7 +58,7 @@ To-Do

Better error handling.

More REST API calls (e.g. meta data edit, cover image upload).
More REST API calls (e.g. collection management).

Support for more resellers.

Expand Down
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
certifi==2020.4.5.1
chardet==3.0.4
idna==2.9
requests==2.23.0
urllib3==1.25.9
34 changes: 34 additions & 0 deletions tolinoclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,23 @@ def delete(args):
c.logout()
print('deleted {} from tolino cloud.'.format(args.document_id))

def meta(args):
c = TolinoCloud(args.partner)
c.login(args.user, args.password)
c.register()
c.metadata(args.document_id, args.title, args.subtitle, args.author, args.publisher, args.isbn, args.edition, args.issued, args.language)
c.unregister()
c.logout()
print('successfully modified book {}'.format(args.document_id))

def cover(args):
c = TolinoCloud(args.partner)
c.login(args.user, args.password)
c.register()
c.cover(args.document_id, args.image)
c.unregister()
c.logout()
print('successfully modified cover for book {}'.format(args.document_id))

parser = argparse.ArgumentParser(
description='cmd line client to access personal tolino cloud storage space.'
Expand All @@ -115,6 +132,23 @@ def delete(args):
s = subparsers.add_parser('inventory', help='fetch and print inventory')
s.set_defaults(func=inventory)

s = subparsers.add_parser('meta', help='set new meta data')
s.add_argument('document_id')
s.add_argument('--title', help='set a new title <string> eg. "Book Title 1"')
s.add_argument('--subtitle', help='set a new subtitle <string> eg. "Subtitle 1"')
s.add_argument('--author', help='set a new author <string> eg. "Hans Muster"')
s.add_argument('--publisher', help='set a new publisher <string> eg. "Carlsen Verlag"')
s.add_argument('--isbn', help='set a new isbn <string> eg."977-3-958-39650-2"')
s.add_argument('--edition', help='set a new edition <int> eg. "3"')
s.add_argument('--issued', help='set a new issued date <int> eg. "01.01.2019" ')
s.add_argument('--language', help='set a new language <string> eg. "en"')
s.set_defaults(func=meta)

s = subparsers.add_parser('cover', help='upload a cover for a specific book')
s.add_argument('document_id')
s.add_argument('image', metavar='IMAGE', help="must be a .png or .jpg")
s.set_defaults(func=cover)

s = subparsers.add_parser('upload', help='upload a file (must be either .pdf or .epub)')
s.add_argument('filename', metavar='FILE')
s.add_argument('--name', help='specify an alternative name')
Expand Down
3 changes: 3 additions & 0 deletions tolinoclient.py.fish
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function __fish_tolino_partners
echo "0 List partners"
echo "3 thalia.de"
echo "6 buch.de"
echo "8 book.ch / orellfuessli.ch"
echo "13 hugendubel.de"
end

Expand All @@ -45,6 +46,8 @@ complete -c $PROG --no-files

# Subcommands
complete -c $PROG -n '__fish_tolino_needs_command' -a 'inventory' -d 'Fetch and print inventory'
complete -c $PROG -n '__fish_tolino_needs_command' -a 'meta' -d 'Update meta data of a book'
complete -c $PROG -n '__fish_tolino_needs_command' -a 'cover' -d 'Update cover of a book'
complete -c $PROG -n '__fish_tolino_needs_command' -a 'upload' -d 'Upload a file (must be either .pdf or .epub)'
complete -c $PROG -n '__fish_tolino_needs_command' -a 'download' -d 'Download a document'
complete -c $PROG -n '__fish_tolino_needs_command' -a 'delete' -d 'Delete a document (be careful!)'
Expand Down
Loading