Ejemplo n.º 1
0
    def _send_to_ipod(self, episodes):
        itdb = gpod.itdb_parse(self.ipod_mount, None)
        if not itdb:
            logger.error('Could not open iPod database at %s' % self.ipod_mount)
            self.ipod_mount = None
            return

        for episode in reversed(episodes):
            filename = episode.local_filename(create=False)
            if filename is None:
                continue

            extension = episode.extension()
            basename = os.path.splitext(os.path.basename(filename))[0]

            if episode.file_type() != 'audio':
                continue

            sent = False  # set to true if file transfer was successful
            # for each file type:
            # 1. extract (id3) tags
            # 2. fix missing tags using available information
            # 3. convert file to mp3 if necessary
            # 4. send to iPod
            if extension.lower() == '.mp3':
                tags = _get_MP3_tags(filename)
                sent = self.send_file_to_ipod(itdb, filename, _fix_tags(tags, episode, basename))
            elif extension.lower() == '.ogg':
                tmpname = _convert_to_mp3(filename)
                if tmpname:
                    sent = self.send_file_to_ipod(itdb, tmpname, _get_OGG_tags(filename))
                    os.unlink(tmpname);
            elif extension.lower() == '.wav':
                tags = {}
                tmpname = _convert_to_mp3(filename)
                if tmpname:
                    sent = self.send_file_to_ipod(itdb, tmpname, _fix_tags({}, episode, basename))
                    os.unlink(tmpname);
            else:
                continue

            if sent:
                episode.mark_old()
                logger.info("File '%s' has been marked 'old'" % filename)
                if not episode.archive:
                  episode.delete_from_disk()
                  logger.info("File '%s' has been deleted from gPodder database and file system"
                              % filename)
                # update UI
                if self.ui:
                  self.ui.episode_list_status_changed([episode])

        gpod.itdb_free(itdb)
Ejemplo n.º 2
0
 def __del__(self):
     gpod.itdb_free(self._itdb)
Ejemplo n.º 3
0
 def __del__(self):
     gpod.itdb_free(self._itdb)