Added grabbing of pdf ebooks corresponding to edition
parent
997b771a6b
commit
f73aa1b570
|
@ -103,11 +103,18 @@ def add_by_googlebooks_id(googlebooks_id, work=None):
|
||||||
e.public_domain = item.get('public_domain', None)
|
e.public_domain = item.get('public_domain', None)
|
||||||
epub = access_info.get('epub')
|
epub = access_info.get('epub')
|
||||||
if epub and epub.get('downloadLink'):
|
if epub and epub.get('downloadLink'):
|
||||||
ebook = models.Ebook(edition=e,
|
ebook = models.Ebook(edition=e, format='epub',
|
||||||
url=epub.get('downloadLink'),
|
url=epub.get('downloadLink'),
|
||||||
provider='google')
|
provider='google')
|
||||||
ebook.save()
|
ebook.save()
|
||||||
|
|
||||||
|
pdf = access_info.get('pdf')
|
||||||
|
if pdf and pdf.get('downloadLink'):
|
||||||
|
ebook = models.Ebook(edition=e, format='pdf',
|
||||||
|
url=pdf.get('downloadLink', None),
|
||||||
|
provider='google')
|
||||||
|
ebook.save()
|
||||||
|
|
||||||
# if we know what work to add the edition to do it
|
# if we know what work to add the edition to do it
|
||||||
if work:
|
if work:
|
||||||
work.editions.add(e)
|
work.editions.add(e)
|
||||||
|
|
|
@ -110,10 +110,16 @@ class TestBookLoader(TestCase):
|
||||||
|
|
||||||
def test_ebook(self):
|
def test_ebook(self):
|
||||||
edition = bookloader.add_by_oclc('1246014')
|
edition = bookloader.add_by_oclc('1246014')
|
||||||
self.assertEqual(edition.ebooks.count(), 1)
|
self.assertEqual(edition.ebooks.count(), 2)
|
||||||
ebook = edition.ebooks.all()[0]
|
#ebook_epub = edition.ebooks.all()[0]
|
||||||
self.assertEqual(ebook.url, 'http://books.google.com/books/download/The_Latin_language.epub?id=U3FXAAAAYAAJ&ie=ISO-8859-1&output=epub&source=gbs_api')
|
ebook_epub = edition.ebooks.filter(format='epub')[0]
|
||||||
self.assertEqual(ebook.provider, 'google')
|
self.assertEqual(ebook_epub.format, 'epub')
|
||||||
|
self.assertEqual(ebook_epub.url, 'http://books.google.com/books/download/The_Latin_language.epub?id=U3FXAAAAYAAJ&ie=ISO-8859-1&output=epub&source=gbs_api')
|
||||||
|
self.assertEqual(ebook_epub.provider, 'google')
|
||||||
|
ebook_pdf = edition.ebooks.filter(format='pdf')[0]
|
||||||
|
self.assertEqual(ebook_pdf.format, 'pdf')
|
||||||
|
self.assertEqual(ebook_pdf.url, 'http://books.google.com/books/download/The_Latin_language.pdf?id=U3FXAAAAYAAJ&ie=ISO-8859-1&output=pdf&sig=ACfU3U2yLt3nmTncB8ozxOWUc4iHKUznCA&source=gbs_api')
|
||||||
|
self.assertEqual(ebook_pdf.provider, 'google')
|
||||||
|
|
||||||
def test_add_no_ebook(self):
|
def test_add_no_ebook(self):
|
||||||
# this edition lacks an ebook, but we should still be able to load it
|
# this edition lacks an ebook, but we should still be able to load it
|
||||||
|
|
Loading…
Reference in New Issue