diff --git a/cli/google_interface.py b/cli/google_interface.py index 8d6557c..7733d3b 100644 --- a/cli/google_interface.py +++ b/cli/google_interface.py @@ -15,6 +15,8 @@ exit_commands = ['exit', 'abort', 'quit', 'bye', 'eat flaming death', 'q'] comments = "" +encoding = 'utf8' + # midlertidig connection = pgdb.connect(database='oysteini_pbb2', user='oysteini_pbb', @@ -114,18 +116,18 @@ def build_book(entry, authors, indata=False): comment("No ISBN found.") return False - book['title'] = unicode(entry.dc_title[0].text) + book['title'] = unicode(entry.dc_title[0].text, encoding) set_value(book, dic, 'category') if len(entry.dc_title) > 0: - book['subtitle'] = unicode(''.join(map(lambda x: x.text, entry.dc_title[1:]))) + book['subtitle'] = unicode(''.join(map(lambda x: x.text, entry.dc_title[1:])), encoding) book['persons'] = {} book['persons']['author'] = [author['id'] for author in authors] if 'publishers' in dic: - book['publisher'] = unicode(','.join(dic['publishers'])) + book['publisher'] = unicode(','.join(dic['publishers']), encoding) if 'date' in dic: book['published_year'] = int(dic['date'][:4]) @@ -136,10 +138,10 @@ def build_book(entry, authors, indata=False): set_value(book, dic, 'series') - book['description'] = unicode(find_description(dic)) + book['description'] = unicode(find_description(dic), encoding) book['references'] = {} - book['references']['google-books'] = [unicode(dic['preview'])] + book['references']['google-books'] = [unicode(dic['preview'], encoding)] return book @@ -149,7 +151,7 @@ def comment(comm): def set_value(book, dic, key): if key in dic: - book[key] = unicode(dic[key]) + book[key] = unicode(dic[key], encoding) else: book[key] = None