Skip to content
Salman Shah edited this page Jul 10, 2018 · 1 revision

Edition

1. Creating a new Edition on Open Library

Creates this book as an Edition associated with the work having olid work_olid

>>> from olclient import OpenLibrary
>>> ol = OpenLibrary()
>>> = ol.Edition.create(Book(...), u'OL2514725W')

2. JSON to Book Object

Creates a Book Object using the JSON that is input

import json
data =  json.dumps({"title":"XXX", "authors":["XXX","XXX"], "publisher":"XXX", "publish_date":"XXX"})
>>> from olclient import OpenLibrary
>>> ol = OpenLibrary()
>>> = ol.Edition.json_to_book(data)

Note:

Method is still not done properly. Related Issue

3. Fetching Book Arguments from OL Edition JSON

Creates Book Arguments from OL Edition JSON

import json
json = {"edition_olid":"XXX", "authors":["XXX","XXX"], "work_olid":"XXX"}
>>> from olclient import OpenLibrary
>>> ol = OpenLibrary()
>>> = ol.Edition._ol_edition_json_to_book_args(data)

4. Retrieving book from Open Library using Identifiers

Retrieves a single book from OpenLibrary as json by isbn or olid or ociad or lccn or oclc or olid.

>>> from olclient import OpenLibrary
>>> ol = OpenLibrary()
>>> ol.Edition.get(olid=u'OL25944230M')
>>> from olclient import OpenLibrary
>>> ol = OpenLibrary()
>>> ol.Edition.get(isbn=u'9706664998')
>>> from olclient import OpenLibrary
>>> ol = OpenLibrary()
>>> ol.Edition.get(oclc=u'893562252')
>>> from olclient import OpenLibrary
>>> ol = OpenLibrary()
>>> ol.Edition.get(lccn=u'XXX')
>>> from olclient import OpenLibrary
>>> ol = OpenLibrary()
>>> ol.Edition.get(ocaid=u'XXX')

5. Get Open Library Edition JSON

Looks up a key (LCCN, OCLC, ISBN10/13, OCAID) in OpenLibrary and returns a matching olid if a match exists.

>>> from olclient import OpenLibrary
>>> ol = OpenLibrary()
>>> ol.Edition.get_metadata(u'ISBN', u'9780747550303')
>>> from olclient import OpenLibrary
>>> ol = OpenLibrary()
>>> ol.Edition.get_metadata(u'LCCN', u'XXX')
>>> from olclient import OpenLibrary
>>> ol = OpenLibrary()
>>> ol.Edition.get_metadata(u'OCLC', u'XXX')
>>> from olclient import OpenLibrary
>>> ol = OpenLibrary()
>>> ol.Edition.get_metadata(u'OCAID', u'XXX')

Process to add an Edition to Open Library

Note:

Please ensure you have a bot account to run this.

>>> from olclient.openlibrary import OpenLibrary
>>> ol = OpenLibrary()
>>> edition = ol.Edition.get(u'OL25952968M')
>>> authors = edition.authors
>>> work = edition.work
>>> work.add_bookcover(u'https://covers.openlibrary.org/b/id/7451891-L.jpg')
>>> edition.add_bookcover(u'https://covers.openlibrary.org/b/id/7451891-L.jpg')

Clone this wiki locally