mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from trunk
This commit is contained in:
commit
683f204466
@ -43,7 +43,8 @@ class TazDigiabo(BasicNewsRecipe):
|
|||||||
f = urllib2.urlopen(url)
|
f = urllib2.urlopen(url)
|
||||||
except urllib2.HTTPError:
|
except urllib2.HTTPError:
|
||||||
self.report_progress(0,_('Can\'t login to download issue'))
|
self.report_progress(0,_('Can\'t login to download issue'))
|
||||||
return
|
raise ValueError('Failed to login, check your username and'
|
||||||
|
' password')
|
||||||
|
|
||||||
tmp = tempfile.TemporaryFile()
|
tmp = tempfile.TemporaryFile()
|
||||||
self.report_progress(0,_('downloading epub'))
|
self.report_progress(0,_('downloading epub'))
|
||||||
|
@ -1105,6 +1105,7 @@ class OPFCreator(MetaInformation):
|
|||||||
spine.set('toc', 'ncx')
|
spine.set('toc', 'ncx')
|
||||||
if self.spine is not None:
|
if self.spine is not None:
|
||||||
for ref in self.spine:
|
for ref in self.spine:
|
||||||
|
if ref.id is not None:
|
||||||
spine.append(E.itemref(idref=ref.id))
|
spine.append(E.itemref(idref=ref.id))
|
||||||
guide = E.guide()
|
guide = E.guide()
|
||||||
if self.guide is not None:
|
if self.guide is not None:
|
||||||
|
@ -1306,15 +1306,14 @@ class DeviceMixin(object): # {{{
|
|||||||
def book_on_device(self, id, format=None, reset=False):
|
def book_on_device(self, id, format=None, reset=False):
|
||||||
'''
|
'''
|
||||||
Return an indication of whether the given book represented by its db id
|
Return an indication of whether the given book represented by its db id
|
||||||
is on the currently connected device. It returns a 6 element list. The
|
is on the currently connected device. It returns a 5 element list. The
|
||||||
first three elements represent memory locations main, carda, and cardb,
|
first three elements represent memory locations main, carda, and cardb,
|
||||||
and are true if the book is identifiably in that memory. The fourth
|
and are true if the book is identifiably in that memory. The fourth
|
||||||
is a count of how many instances of the book were found across all
|
is a count of how many instances of the book were found across all
|
||||||
the memory locations. The fifth is the type of match. The type can be
|
the memory locations. The fifth is a set of paths to the
|
||||||
one of: None, 'uuid', 'db_id', 'metadata'. The sixth is a set of paths to the
|
|
||||||
matching books on the device.
|
matching books on the device.
|
||||||
'''
|
'''
|
||||||
loc = [None, None, None, 0, None, set([])]
|
loc = [None, None, None, 0, set([])]
|
||||||
|
|
||||||
if reset:
|
if reset:
|
||||||
self.book_db_id_cache = None
|
self.book_db_id_cache = None
|
||||||
@ -1322,10 +1321,8 @@ class DeviceMixin(object): # {{{
|
|||||||
self.book_db_uuid_path_map = None
|
self.book_db_uuid_path_map = None
|
||||||
return
|
return
|
||||||
|
|
||||||
string_pat = re.compile('(?u)\W|[_]')
|
if not hasattr(self, 'db_book_uuid_cache'):
|
||||||
def clean_string(x):
|
return loc
|
||||||
x = x.lower() if x else ''
|
|
||||||
return string_pat.sub('', x)
|
|
||||||
|
|
||||||
if self.book_db_id_cache is None:
|
if self.book_db_id_cache is None:
|
||||||
self.book_db_id_cache = []
|
self.book_db_id_cache = []
|
||||||
@ -1343,6 +1340,7 @@ class DeviceMixin(object): # {{{
|
|||||||
self.book_db_id_cache[i].add(db_id)
|
self.book_db_id_cache[i].add(db_id)
|
||||||
if db_id not in self.book_db_uuid_path_map:
|
if db_id not in self.book_db_uuid_path_map:
|
||||||
self.book_db_uuid_path_map[db_id] = set()
|
self.book_db_uuid_path_map[db_id] = set()
|
||||||
|
if getattr(book, 'lpath', False):
|
||||||
self.book_db_uuid_path_map[db_id].add(book.lpath)
|
self.book_db_uuid_path_map[db_id].add(book.lpath)
|
||||||
c = self.book_db_id_counts.get(db_id, 0)
|
c = self.book_db_id_counts.get(db_id, 0)
|
||||||
self.book_db_id_counts[db_id] = c + 1
|
self.book_db_id_counts[db_id] = c + 1
|
||||||
@ -1351,9 +1349,7 @@ class DeviceMixin(object): # {{{
|
|||||||
if id in self.book_db_id_cache[i]:
|
if id in self.book_db_id_cache[i]:
|
||||||
loc[i] = True
|
loc[i] = True
|
||||||
loc[3] = self.book_db_id_counts.get(id, 0)
|
loc[3] = self.book_db_id_counts.get(id, 0)
|
||||||
loc[4] = 'uuid'
|
loc[4] |= self.book_db_uuid_path_map[id]
|
||||||
loc[5] |= self.book_db_uuid_path_map[id]
|
|
||||||
continue
|
|
||||||
return loc
|
return loc
|
||||||
|
|
||||||
def set_books_in_library(self, booklists, reset=False):
|
def set_books_in_library(self, booklists, reset=False):
|
||||||
@ -1434,7 +1430,7 @@ class DeviceMixin(object): # {{{
|
|||||||
continue
|
continue
|
||||||
# Sonys know their db_id independent of the application_id
|
# Sonys know their db_id independent of the application_id
|
||||||
# in the metadata cache. Check that as well.
|
# in the metadata cache. Check that as well.
|
||||||
if book.db_id in d['db_ids']:
|
if getattr(book, 'db_id', None) in d['db_ids']:
|
||||||
book.in_library = True
|
book.in_library = True
|
||||||
book.application_id = \
|
book.application_id = \
|
||||||
d['db_ids'][book.db_id].application_id
|
d['db_ids'][book.db_id].application_id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user