mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Sony driver: Ignore invalid strings when updating XML database
This commit is contained in:
parent
c0b9885be0
commit
caf4b2350f
@ -619,6 +619,13 @@ class XMLCache(object):
|
|||||||
x.replace(u'\0', '')
|
x.replace(u'\0', '')
|
||||||
return x
|
return x
|
||||||
|
|
||||||
|
def record_set(k, v):
|
||||||
|
try:
|
||||||
|
record.set(k, clean(v))
|
||||||
|
except:
|
||||||
|
# v is not suitable for XML, ignore
|
||||||
|
pass
|
||||||
|
|
||||||
if not getattr(book, '_new_book', False): # book is not new
|
if not getattr(book, '_new_book', False): # book is not new
|
||||||
if record.get('tz', None) is not None:
|
if record.get('tz', None) is not None:
|
||||||
use_tz_var = True
|
use_tz_var = True
|
||||||
@ -641,20 +648,20 @@ class XMLCache(object):
|
|||||||
record.set('date', clean(date))
|
record.set('date', clean(date))
|
||||||
record.set('size', clean(str(os.stat(path).st_size)))
|
record.set('size', clean(str(os.stat(path).st_size)))
|
||||||
title = book.title if book.title else _('Unknown')
|
title = book.title if book.title else _('Unknown')
|
||||||
record.set('title', clean(title))
|
record_set('title', title)
|
||||||
ts = book.title_sort
|
ts = book.title_sort
|
||||||
if not ts:
|
if not ts:
|
||||||
ts = title_sort(title)
|
ts = title_sort(title)
|
||||||
record.set('titleSorter', clean(ts))
|
record_set('titleSorter', ts)
|
||||||
if self.use_author_sort:
|
if self.use_author_sort:
|
||||||
if book.author_sort:
|
if book.author_sort:
|
||||||
aus = book.author_sort
|
aus = book.author_sort
|
||||||
else:
|
else:
|
||||||
debug_print('Author_sort is None for book', book.lpath)
|
debug_print('Author_sort is None for book', book.lpath)
|
||||||
aus = authors_to_sort_string(book.authors)
|
aus = authors_to_sort_string(book.authors)
|
||||||
record.set('author', clean(aus))
|
record_set('author', aus)
|
||||||
else:
|
else:
|
||||||
record.set('author', clean(authors_to_string(book.authors)))
|
record_set('author', authors_to_string(book.authors))
|
||||||
ext = os.path.splitext(path)[1]
|
ext = os.path.splitext(path)[1]
|
||||||
if ext:
|
if ext:
|
||||||
ext = ext[1:].lower()
|
ext = ext[1:].lower()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user