fikset litt på gdata-modulen
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
from web.library.models import *
|
||||
from gdata.books.service import BookService
|
||||
import re
|
||||
|
||||
exit_commands = ['exit', 'abort', 'quit', 'bye', 'eat flaming death', 'q']
|
||||
|
||||
@@ -22,8 +23,8 @@ def get_book_loop():
|
||||
|
||||
def build_book(entry, input=False):
|
||||
dic = entry.to_dict()
|
||||
# print dic
|
||||
print entry
|
||||
print dic
|
||||
# print entry
|
||||
b = Book(title=entry.dc_title[0].text)
|
||||
if len(entry.dc_title) > 0:
|
||||
b.subtitle = ''.join(map(lambda x: x.text, entry.dc_title[1:]))
|
||||
@@ -42,9 +43,18 @@ def build_book(entry, input=False):
|
||||
b.published_year = int(dic['date'][:4])
|
||||
if 'publishers' in dic:
|
||||
b.publisher = ','.join(dic['publishers'])
|
||||
print entry.format
|
||||
b.num_pages = find_page_number(dic)
|
||||
b.full_print()
|
||||
|
||||
def find_page_number(dic):
|
||||
if 'format' in dic:
|
||||
for item in dic['format']:
|
||||
if 'pages' in item:
|
||||
return int(re.findall(r'[0-9]+',item)[0])
|
||||
return None
|
||||
else:
|
||||
return None
|
||||
|
||||
def find_isbn(identifiers):
|
||||
for pair in identifiers:
|
||||
if pair[0] =='ISBN' and len(pair[1])==13:
|
||||
|
||||
Reference in New Issue
Block a user