mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Only send news to device if the device supports the format the news has been downloaded in
This commit is contained in:
parent
ab0c2accef
commit
17df10b5a2
@ -385,13 +385,35 @@ class BooksModel(QAbstractTableModel):
|
||||
metadata.append(mi)
|
||||
return metadata
|
||||
|
||||
def get_preferred_formats_from_ids(self, ids, all_formats, mode='r+b'):
|
||||
ans = []
|
||||
for id in ids:
|
||||
format = None
|
||||
fmts = self.db.formats(id, index_is_id=True)
|
||||
if not fmts:
|
||||
fmts = ''
|
||||
available_formats = set(fmts.lower().split(','))
|
||||
for f in all_formats:
|
||||
if f.lower() in available_formats:
|
||||
format = f.lower()
|
||||
break
|
||||
if format is None:
|
||||
ans.append(format)
|
||||
else:
|
||||
f = self.db.format(id, format, index_is_id=True, as_file=True,
|
||||
mode=mode)
|
||||
ans.append(f)
|
||||
return ans
|
||||
|
||||
|
||||
|
||||
def get_preferred_formats(self, rows, formats, paths=False):
|
||||
ans = []
|
||||
for row in (row.row() for row in rows):
|
||||
format = None
|
||||
fmts = self.db.formats(row)
|
||||
if not fmts:
|
||||
return []
|
||||
fmts = ''
|
||||
db_formats = set(fmts.lower().split(','))
|
||||
available_formats = set([f.lower() for f in formats])
|
||||
u = available_formats.intersection(db_formats)
|
||||
|
@ -887,7 +887,8 @@ class Main(MainWindow, Ui_MainWindow):
|
||||
if self.device_connected:
|
||||
ids = list(dynamic.get('news_to_be_synced', set([])))
|
||||
ids = [id for id in ids if self.library_view.model().db.has_id(id)]
|
||||
files = [self.library_view.model().db.format(id, prefs['output_format'], index_is_id=True, as_file=True) for id in ids]
|
||||
files = self.library_view.model().get_preferred_formats_from_ids(
|
||||
ids, self.device_manager.device_class.FORMATS)
|
||||
files = [f for f in files if f is not None]
|
||||
if not files:
|
||||
dynamic.set('news_to_be_synced', set([]))
|
||||
|
Loading…
x
Reference in New Issue
Block a user