From b8018f59f29eaf7c5036c704f6c4baa92fda9165 Mon Sep 17 00:00:00 2001 From: GRiker Date: Thu, 27 Oct 2011 13:53:43 -0600 Subject: [PATCH 1/3] WIP - conform epub metadata with calibre --- src/calibre/devices/apple/driver.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/devices/apple/driver.py b/src/calibre/devices/apple/driver.py index 645b2fb606..289d5079f4 100644 --- a/src/calibre/devices/apple/driver.py +++ b/src/calibre/devices/apple/driver.py @@ -1305,6 +1305,8 @@ class ITUNES(DriverBase): if DEBUG: self.log.info(" ITUNES._add_new_copy()") + self._update_epub_metadata(fpath, metadata) + db_added = None lb_added = None @@ -2663,6 +2665,7 @@ class ITUNES(DriverBase): metadata.timestamp = now() if DEBUG: self.log.info(" add timestamp: %s" % metadata.timestamp) + else: metadata.timestamp = now() if DEBUG: @@ -2699,7 +2702,7 @@ class ITUNES(DriverBase): if iswindows and metadata.series: metadata.tags = None - set_metadata(zfo, metadata, update_timestamp=True) + set_metadata(zfo, metadata, apply_null=True, update_timestamp=True) def _update_device(self, msg='', wait=True): ''' From 5c7bf560c2ec37867f7a1fd5e128ca5dafbb3a9a Mon Sep 17 00:00:00 2001 From: GRiker Date: Fri, 18 Nov 2011 05:18:15 -0700 Subject: [PATCH 2/3] Added iPhone 4S device fingerprint --- src/calibre/devices/apple/driver.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/devices/apple/driver.py b/src/calibre/devices/apple/driver.py index 289d5079f4..9a242b245d 100644 --- a/src/calibre/devices/apple/driver.py +++ b/src/calibre/devices/apple/driver.py @@ -217,10 +217,11 @@ class ITUNES(DriverBase): # 0x1297 iPhone 4 # 0x129a iPad # 0x129f iPad2 (WiFi) + # 0x12a0 iPhone 4S # 0x12a2 iPad2 (GSM) # 0x12a3 iPad2 (CDMA) VENDOR_ID = [0x05ac] - PRODUCT_ID = [0x1292,0x1293,0x1294,0x1297,0x1299,0x129a,0x129f,0x12a2,0x12a3] + PRODUCT_ID = [0x1292,0x1293,0x1294,0x1297,0x1299,0x129a,0x129f,0x12a0,0x12a2,0x12a3] BCD = [0x01] # Plugboard ID From 6ddaa374ce7e2a73037a223ce3aec5d07411a8a6 Mon Sep 17 00:00:00 2001 From: GRiker Date: Sat, 19 Nov 2011 08:59:58 -0700 Subject: [PATCH 3/3] Rewrite metadata header, removing dc:subject tags, added more error handling for Windows/iTunes artwork error, added iPhone 4S device ID (not enabled) --- src/calibre/devices/apple/driver.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/calibre/devices/apple/driver.py b/src/calibre/devices/apple/driver.py index 9a242b245d..2f7c1a9d20 100644 --- a/src/calibre/devices/apple/driver.py +++ b/src/calibre/devices/apple/driver.py @@ -221,7 +221,7 @@ class ITUNES(DriverBase): # 0x12a2 iPad2 (GSM) # 0x12a3 iPad2 (CDMA) VENDOR_ID = [0x05ac] - PRODUCT_ID = [0x1292,0x1293,0x1294,0x1297,0x1299,0x129a,0x129f,0x12a0,0x12a2,0x12a3] + PRODUCT_ID = [0x1292,0x1293,0x1294,0x1297,0x1299,0x129a,0x129f,0x12a2,0x12a3] BCD = [0x01] # Plugboard ID @@ -1412,10 +1412,16 @@ class ITUNES(DriverBase): tmp_cover.write(cover_data) if lb_added: - if lb_added.Artwork.Count: - lb_added.Artwork.Item(1).SetArtworkFromFile(tc) - else: - lb_added.AddArtworkFromFile(tc) + try: + if lb_added.Artwork.Count: + lb_added.Artwork.Item(1).SetArtworkFromFile(tc) + else: + lb_added.AddArtworkFromFile(tc) + except: + if DEBUG: + self.log.warning(" iTunes automation interface reported an error" + " when adding artwork to '%s' in the iTunes Library" % metadata.title) + pass if db_added: if db_added.Artwork.Count: @@ -2775,6 +2781,8 @@ class ITUNES(DriverBase): lb_added.sort_name.set(metadata_x.title_sort) if db_added: + self.log.warning(" waiting for db_added to become writeable ") + time.sleep(1.0) db_added.name.set(metadata_x.title) db_added.album.set(metadata_x.title) db_added.artist.set(authors_to_string(metadata_x.authors))