mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
Implement #259
This commit is contained in:
parent
81c01f4561
commit
246c3520c1
@ -127,7 +127,7 @@ class BooksModel(QAbstractTableModel):
|
|||||||
|
|
||||||
def save_to_disk(self, rows, path):
|
def save_to_disk(self, rows, path):
|
||||||
rows = [row.row() for row in rows]
|
rows = [row.row() for row in rows]
|
||||||
self.db.export_to_dir(path, rows)
|
self.db.export_to_dir(path, rows, self.sorted_on[0] == 1)
|
||||||
|
|
||||||
def delete_books(self, indices):
|
def delete_books(self, indices):
|
||||||
ids = [ self.id(i) for i in indices ]
|
ids = [ self.id(i) for i in indices ]
|
||||||
|
@ -1060,7 +1060,7 @@ ALTER TABLE books ADD COLUMN isbn TEXT DEFAULT "" COLLATE NOCASE;
|
|||||||
self.conn.execute('DELETE FROM books WHERE id=?', (id,))
|
self.conn.execute('DELETE FROM books WHERE id=?', (id,))
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
|
|
||||||
def export_to_dir(self, dir, indices):
|
def export_to_dir(self, dir, indices, byauthor=False):
|
||||||
by_author = {}
|
by_author = {}
|
||||||
for index in indices:
|
for index in indices:
|
||||||
id = self.id(index)
|
id = self.id(index)
|
||||||
@ -1086,7 +1086,8 @@ ALTER TABLE books ADD COLUMN isbn TEXT DEFAULT "" COLLATE NOCASE;
|
|||||||
os.mkdir(tpath)
|
os.mkdir(tpath)
|
||||||
for fmt in self.formats(idx).split(','):
|
for fmt in self.formats(idx).split(','):
|
||||||
data = self.format(idx, fmt)
|
data = self.format(idx, fmt)
|
||||||
f = open(os.path.join(tpath, title + ' - ' + au +'_'+id+'.'+fmt.lower()), 'wb')
|
name = au + ' - ' + title if byauthor else title + ' - ' + au
|
||||||
|
f = open(os.path.join(tpath, name +'_'+id+'.'+fmt.lower()), 'wb')
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user