Commit 312cdd6d authored by Mattia Bondanza's avatar Mattia Bondanza

First implementation of ISBN research with OpenLibrary API.

parent 8738582e
......@@ -47,6 +47,6 @@ def metadataISBNGetTitle( mdt ):
def printMetadataForISBN( isbn ):
mdt = metadataFromISBN( isbn )
if mdt['author'] is not '' and mdt['title'] is not '':
print "( A:\x1b[33m", mdt['author'], "\x1b[0mT:\x1b[32m", mdt['title'], "\x1b[0m)"
print "( S:ISBN+ A:\x1b[33m", mdt['author'], "\x1b[0mT:\x1b[32m", mdt['title'], "\x1b[0m)",
else:
print "\x1b[31mNo metadata found.\x1b[0m"
print "\x1b[31m( S:ISBN+ No metadata found.)\x1b[0m",
......@@ -9,6 +9,7 @@ import slate
from pypdfocr import pypdfocr as pypdfocr
import isbnPLUS
import OpenLibrary
def getPDFContent(path):
content = ""
......@@ -70,30 +71,42 @@ def searchISBNstrings( cnt ):
out.append( strippedisbn[2:12] )
print "\x1b[33m[debug]\x1b[0m\t\tAggiunto:\x1b[1m", out[len(out)-1], "\x1b[22m ",
isbnPLUS.printMetadataForISBN( out[len(out)-1] )
OpenLibrary.printMetadataForISBN( out[len(out)-1] )
print
if checkISBN10( strippedisbn[0:10] ):
out.append( strippedisbn[0:10] )
print "\x1b[33m[debug]\x1b[0m\t\tAggiunto:\x1b[1m", out[len(out)-1], "\x1b[22m ",
isbnPLUS.printMetadataForISBN( out[len(out)-1] )
OpenLibrary.printMetadataForISBN( out[len(out)-1] )
print
elif strippedisbn[0:2] == '13':#Puo' essere un ISBN10 che comincia con 13 oppure un ISBN13 con 13 davanti. Non può essere ISBN13 che inizia con 13 perché le prime 3 cifre sono sempre 978 per ISBN13
print "\x1b[33m[debug]\x1b[0m\t\tPenso sia un ISBN13."
if checkISBN10( strippedisbn[0:10] ):
out.append( strippedisbn[0:10] )
print "\x1b[33m[debug]\x1b[0m\t\tAggiunto:\x1b[1m", out[len(out)-1], "\x1b[22m ",
isbnPLUS.printMetadataForISBN( out[len(out)-1] )
OpenLibrary.printMetadataForISBN( out[len(out)-1] )
print
if checkISBN13( strippedisbn[2:15] ):
out.append( strippedisbn[2:15] )
print "\x1b[33m[debug]\x1b[0m\t\tAggiunto:\x1b[1m", out[len(out)-1], "\x1b[22m ",
isbnPLUS.printMetadataForISBN( out[len(out)-1] )
OpenLibrary.printMetadataForISBN( out[len(out)-1] )
print
else:
print "\x1b[33m[debug]\x1b[0m\t\tNon so se sia un ISBN10 o un ISBN13."
if checkISBN13( strippedisbn[0:13] ):
out.append( strippedisbn[0:13] )
print "\x1b[33m[debug]\x1b[0m\t\tAggiunto:\x1b[1m", out[len(out)-1], "\x1b[22m ",
isbnPLUS.printMetadataForISBN( out[len(out)-1] )
OpenLibrary.printMetadataForISBN( out[len(out)-1] )
print
if checkISBN10( strippedisbn[0:10] ):
out.append( strippedisbn[0:10] )
print "\x1b[33m[debug]\x1b[0m\t\tAggiunto:\x1b[1m", out[len(out)-1], "\x1b[22m ",
isbnPLUS.printMetadataForISBN( out[len(out)-1] )
OpenLibrary.printMetadataForISBN( out[len(out)-1] )
print
if len(out) == old_len:
print "\x1b[33m[debug]\x1b[0m\t\t\x1b[1m\x1b[34mNon ho aggiunto nulla.\x1b[22m\x1b[0m "
bg = pos
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment