'Assumes pythoncom for windows
wait is passed when launching iTunes, as it seems to need a moment to come to its senses'

def _discover_manual_sync_mode(self, wait=0):

    if self.verbose:
        logger().info(('    %s._discover_manual_sync_mode()' % self.__class__.__name__))
    if wait:
        time.sleep(wait)
    if isosx:
        import appscript
        connected_device = self.sources['iPod']
        dev_books = None
        device = self.iTunes.sources[connected_device]
        for pl in device.playlists():
            if (pl.special_kind() == appscript.k.Books):
                dev_books = pl.file_tracks()
                break
        else:
            logger().error('            book_playlist    not    found')
        if ((dev_books is not None) and len(dev_books)):
            first_book = dev_books[0]
            if False:
                logger().info(("        determining    manual    mode    by    modifying    '%s'    by    %s" % (first_book.name(), first_book.artist())))
            try:
                first_book.bpm.set(0)
                self.manual_sync_mode = True
            except:
                self.manual_sync_mode = False
        else:
            if self.verbose:
                logger().info('            adding    tracer    to    empty    Books|Playlist')
            try:
                added = pl.add(appscript.mactypes.File(P('tracer.epub')), to=pl)
                time.sleep(0.5)
                added.delete()
                self.manual_sync_mode = True
            except:
                self.manual_sync_mode = False
    elif iswindows:
        connected_device = self.sources['iPod']
        device = self.iTunes.sources.ItemByName(connected_device)
        dev_books = None
        for pl in device.Playlists:
            if ((pl.Kind == self.PlaylistKind.index('User')) and (pl.SpecialKind == self.PlaylistSpecialKind.index('Books'))):
                dev_books = pl.Tracks
                break
        if ((dev_books is not None) and dev_books.Count):
            first_book = dev_books.Item(1)
            try:
                first_book.BPM = 0
                self.manual_sync_mode = True
            except:
                self.manual_sync_mode = False
        else:
            if self.verbose:
                logger().info('            sending    tracer    to    empty    Books|Playlist')
            fpath = P('tracer.epub')
            mi = MetaInformation('Tracer', ['calibre'])
            try:
                added = self._add_device_book(fpath, mi)
                time.sleep(0.5)
                added.Delete()
                self.manual_sync_mode = True
            except:
                self.manual_sync_mode = False
    if self.verbose:
        logger().info(('            iTunes.manual_sync_mode:    %s' % self.manual_sync_mode))
