Package: dibuk
Dibuk Bindings for PythonA Python library forDibuk's API v2.3 to work with and order e-books in their catalogue.The bindings allow you to:Get book categoriesGet the catalogue of all booksGet single books details with links to previewsCheck if given book has been previously bought by a given userCreate order for multiple books at onceGet download links for given books previously bought by a userSetupYou can install this package by using the pip tool and installing:pip install dibukSeedocumentationfor instructions on installingpip. If you are on a system witheasy_installbut notpip, you can useeasy_installinstead. If you're not usingvirtualenv, you may have to prefix those commands withsudo.Install from source with:python setup.py installTo install viarequirementsfile from your project, for this moment add the following in before updating dependencies:git+https://github.com/palosopko/dibuk-python.git#egg=dibukUsageFirst off, you need to require the library and provide authentication information by providing your user handle and shared secret you got from the provider.import dibuk
dibuk.api_credentials = (123, '00000000000000000000000000000000')Getting categoriesis accomplished by callingdibuk.Category.all(). The method returns dictionary with category IDs as keys andCategoryobject as values.Categoryobject includesid,parent_idandnameof the category.Getting catalogueworks analogously to previous method for getting categories. You call it withdibuk.Catalogue.all()with optional argument of either typeint(UNIX timestamp) ordatetime.datetimenoting the time of last synchronization to get only changed books since that time. The method returns dictionary with book IDs as keys andBookobject as values.Toget details of a single book,dibuk.Book.get()method should be run with Dibuk's book ID as its argument. Upon success aBookobject is returned.dibuk.Book.available()should be runto check whether a book has been previously boughtby a user with Dibuk's book ID and your user identifier that you have used when creating the order.Tocreate a new orderyou need to rundibuk.Order.create()with list of tuples with Dibuk's book ID and its price as the first argument, you user identifier as the second and a dictionary of required metadata as the third. The method returns dictionary with book IDs as keys and dictionaries with booleanstatusand Dibuk'sorder_idas values.Note:Dibuk's API enforces 1:1 mapping between an order and an e-book so for each book that is in the list in the first argument of the method call, there would be one order created in the Dibuk's system (a.k.a. for each book there is a separate request made).books = [(129, 4.45), (135, 5.50)]
orders = dibuk.Order.create(books, local_user_id, {
    'order_id': local_order_id,
    'user_email': 'istore@artforum.sk',
    'payment_channel': 'PayPal'
})If you would liketo get order detailsyou calldibuk.Order.get()with list of Dibuk's book IDs as the first argument and your local user identifier as the second argument. The method returns dictionary with book IDs as keys and dictionaries with complete list of download links to all available formats as values.ContributingCheck for open issues or open a new issue for a feature request or a bug.Fork the repository and make your changes to the master branch (or branch off of it).Send a pull request.DevelopmentRun all tests on all supported Python versions:make testRun the linter with:make lintThe client library uses Black for code formatting. Code must be formatted with Black before PRs are submitted, otherwise CI will fail. Run the formatter with:make fmtChangelogv0.5.0: 04/01/2024Send user name and surname when creating order if given as it is necessary for social DRM.v0.4.0: 26/07/2023Use API version 2.3 as the default version.v0.3.2: 21/07/2021Use API version 2.2 as the default version. Version 2.1 has been deprecated for some time and even though it could have been set from the application, it is better to have sensible defaults.Refactor getting previews of books including the ability (used internally) to silently ignore exceptions.v0.3.1: 09/01/2021Verify certificate when connecting to Dibuk. Except for being the right thing to do, it also prevents loads of warnings in logs.v0.3.0: 09/01/2021Move over to GitHub, drop support for Python 2.v0.2.3: 19/11/2019Expose license availability; when book might be purchased and license obtained.v0.2.2: 30/09/2019Do not raise error when exporting books with a given timestamp and no books changed.v0.2.1: 24/06/2019Allow signing requests with unicode strings in data in Python 2.v0.2.0: 22/06/2019Set real book formats inBookinstancesFurthermore, Python 3 compatibility has been added for real, code formatting is covered by Black and various small fixes to make everything better and easier including first test.v0.1.10: 19/03/2018Return both the date of publication (inpublished_on, just like it has been) and date of publication of the ebook (inepublished_on) inBookobject.v0.1.9: 10/08/2017Apart from that, allow for including preview information when asking for the whole catalogue.v0.1.8: 20/07/2017Send information about previews insampleskey for consistency with Audiolibrix library.v0.1.7: 07/09/2016Send properly information about previews inpreviewkey containing dictionary with general format (epub, pdf or mobi) as a key and the url to specific file as a value.v0.1.6: 21/09/2015Fixed incorrect setting of availability status in some books.v0.1.5: 16/09/2015Send alsosubtitleattribute toBookobject.v0.1.4: 16/09/2015Fixed problems with encoding non-ascii strings while signing data for request to Dibuk's API.v0.1.3: 03/09/2015Send information of specific formats gotten from Dibuk, not normalize in the three common formats.v0.1.2: 20/08/2015Allow sending ofuser_name,user_surnameanduser_emailparametres to download social DRM'd books indibuk.Order.get()and manual override ofis_mobileparametre.v0.1.1: 05/07/2015Allow installing throughpip(fixes name collision with other package insetup.py)v0.1.0: 15/02/2015Initial version with support for available API methods with minor exceptions (optionalcolumnsargument todetailAPI method (dibuk.Book.get()) etc.)