mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Workaround xisbn sometimes returning incomplete isbn pools
This commit is contained in:
parent
16ca0fa068
commit
5e914a5a20
@ -85,7 +85,11 @@ class ISBNMerge(object):
|
|||||||
isbns, min_year = xisbn.get_isbn_pool(isbn)
|
isbns, min_year = xisbn.get_isbn_pool(isbn)
|
||||||
if not isbns:
|
if not isbns:
|
||||||
isbns = frozenset([isbn])
|
isbns = frozenset([isbn])
|
||||||
self.pools[isbns] = pool = (min_year, [])
|
if isbns in self.pools:
|
||||||
|
# xISBN had a brain fart
|
||||||
|
pool = self.pools[isbn]
|
||||||
|
else:
|
||||||
|
self.pools[isbns] = pool = (min_year, [])
|
||||||
|
|
||||||
if not self.pool_has_result_from_same_source(pool, result):
|
if not self.pool_has_result_from_same_source(pool, result):
|
||||||
pool[1].append(result)
|
pool[1].append(result)
|
||||||
|
@ -45,6 +45,11 @@ class xISBN(object):
|
|||||||
ans.append(rec)
|
ans.append(rec)
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
def isbns_in_data(self, data):
|
||||||
|
for rec in data:
|
||||||
|
for i in rec.get('isbn', []):
|
||||||
|
yield i
|
||||||
|
|
||||||
def get_data(self, isbn):
|
def get_data(self, isbn):
|
||||||
isbn = self.purify(isbn)
|
isbn = self.purify(isbn)
|
||||||
with self.lock:
|
with self.lock:
|
||||||
@ -57,9 +62,8 @@ class xISBN(object):
|
|||||||
data = []
|
data = []
|
||||||
id_ = len(self._data)
|
id_ = len(self._data)
|
||||||
self._data.append(data)
|
self._data.append(data)
|
||||||
for rec in data:
|
for i in self.isbns_in_data(data):
|
||||||
for i in rec.get('isbn', []):
|
self._map[i] = id_
|
||||||
self._map[i] = id_
|
|
||||||
self._map[isbn] = id_
|
self._map[isbn] = id_
|
||||||
return self._data[self._map[isbn]]
|
return self._data[self._map[isbn]]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user