diff --git a/Changelog.yaml b/Changelog.yaml index 603ac97a40..ec083af809 100644 --- a/Changelog.yaml +++ b/Changelog.yaml @@ -5,7 +5,7 @@ # Also, each release can have new and improved recipes. - version: 0.6.52 - date: 2010-07-30 + date: 2010-05-07 new features: - title: "Support for the Kobo Reader and the HTC Desire" diff --git a/src/calibre/devices/prs505/books.py b/src/calibre/devices/prs505/books.py index 406a139fd1..cb6f4df7c5 100644 --- a/src/calibre/devices/prs505/books.py +++ b/src/calibre/devices/prs505/books.py @@ -390,9 +390,9 @@ class BookList(_BookList): continue db_ids = [i.getAttribute('id') for i in pl.childNodes if hasattr(i, 'getAttribute')] pl_book_ids = [getattr(self.book_by_id(i), 'db_id', None) for i in db_ids] - map = {} + imap = {} for i, j in zip(pl_book_ids, db_ids): - map[i] = j + imap[i] = j pl_book_ids = [i for i in pl_book_ids if i is not None] ordered_ids = [i for i in self.tag_order[title] if i in pl_book_ids] @@ -404,7 +404,7 @@ class BookList(_BookList): child.unlink() for id in ordered_ids: item = self.document.createElement(self.prefix+'item') - item.setAttribute('id', str(map[id])) + item.setAttribute('id', str(imap[id])) pl.appendChild(item) def fix_ids(main, carda, cardb): diff --git a/src/calibre/devices/prs505/driver.py b/src/calibre/devices/prs505/driver.py index e73a341909..f4fc4b0d29 100644 --- a/src/calibre/devices/prs505/driver.py +++ b/src/calibre/devices/prs505/driver.py @@ -121,6 +121,14 @@ class PRS505(CLI, Device): self.report_progress(1.0, _('Getting list of books on device...')) return bl + def filename_callback(self, fname, mi): + if getattr(mi, 'application_id', None) is not None: + base = fname.rpartition('.')[0] + suffix = '_%s'%mi.application_id + if not base.endswith(suffix): + fname = base + suffix + '.' + fname.rpartition('.')[-1] + return fname + def upload_books(self, files, names, on_card=None, end_session=True, metadata=None): diff --git a/src/calibre/devices/usbms/device.py b/src/calibre/devices/usbms/device.py index c84028d699..897baf82ca 100644 --- a/src/calibre/devices/usbms/device.py +++ b/src/calibre/devices/usbms/device.py @@ -825,7 +825,10 @@ class Device(DeviceConfig, DevicePlugin): from calibre.library.save_to_disk import get_components if not isinstance(template, unicode): template = template.decode('utf-8') - extra_components = get_components(template, mdata, fname) + app_id = str(getattr(mdata, 'application_id', '')) + # The SONY readers need to have the db id in the created filename + extra_components = get_components(template, mdata, fname, + length=250-len(app_id)-1) if not extra_components: extra_components.append(sanitize(self.filename_callback(fname, mdata))) diff --git a/src/calibre/library/__init__.py b/src/calibre/library/__init__.py index 49a1107222..3c98db5e8a 100644 --- a/src/calibre/library/__init__.py +++ b/src/calibre/library/__init__.py @@ -26,3 +26,8 @@ def server_config(defaults=None): help=_('The maximum number of matches to return per OPDS query. ' 'This affects Stanza, WordPlayer, etc. integration.')) return c + +def db(): + from calibre.library.database2 import LibraryDatabase2 + from calibre.utils.config import prefs + return LibraryDatabase2(prefs['library_path'])