Exemple #1
0
def synchronize_device(db, config):
    device = sync.open_device(config)
    if device is None:
        print >>sys.stderr, _('No device configured.')
        return False

    def msg(s):
        print >>sys.stderr, s

    device.register('status', msg)
    def callback_progress(index, count):
        d = {'index': index, 'count': count}
        msg(_('Synchronizing: %(index)s of %(count)s') % d)
    device.register('progress', callback_progress)

    if device.open():
        channels = [c for c in PodcastChannel.load_from_db(db, \
                config.download_dir) if c.sync_to_devices]

        for channel in channels:
            episodes = [e for e in channel.get_downloaded_episodes() \
                    if e.was_downloaded(and_exists=True)]
            device.add_tracks(episodes)

        db.commit()
        device.close()
        print >>sys.stderr, _('Device synchronized successfully.')
        return True
    else:
        print >>sys.stderr, _('Error: Cannot open device!')
        return False
Exemple #2
0
    def finish(self):
        """Persist changed data to the database file

        This has to be called from the API user after
        data-changing actions have been carried out.
        """
        podcasts = PodcastChannel.load_from_db(self._db, self._config.download_dir)
        exporter = opml.Exporter(gpodder.subscription_file)
        exporter.write(podcasts)
        self._db.commit()
        return True
Exemple #3
0
    def finish(self):
        """Persist changed data to the database file

        This has to be called from the API user after
        data-changing actions have been carried out.
        """
        podcasts = PodcastChannel.load_from_db(self._db, self._config.download_dir)
        exporter = opml.Exporter(gpodder.subscription_file)
        exporter.write(podcasts)
        self._db.commit()
        return True
Exemple #4
0
def synchronize_device(db, config):
    device = sync.open_device(config)
    if device is None:
        print >> sys.stderr, _('No device configured.')
        return False

    def msg(s):
        print >> sys.stderr, s

    device.register('status', msg)

    def callback_progress(index, count):
        d = {'index': index, 'count': count}
        msg(_('Synchronizing: %(index)s of %(count)s') % d)

    device.register('progress', callback_progress)

    if device.open():
        channels = [c for c in PodcastChannel.load_from_db(db, \
                config.download_dir) if c.sync_to_devices]

        for channel in channels:
            episodes = [e for e in channel.get_downloaded_episodes() \
                    if e.was_downloaded(and_exists=True)]
            device.add_tracks(episodes)

        if config.ipod_purge_old_episodes:
            device.purge()

        db.commit()
        device.close()
        print >> sys.stderr, _('Device synchronized successfully.')
        return True
    else:
        print >> sys.stderr, _('Error: Cannot open device!')
        return False
Exemple #5
0
    def get_podcasts(self):
        """Get a list of Podcast objects

        Returns all the subscribed podcasts from gPodder.
        """
        return [Podcast(p, self) for p in PodcastChannel.load_from_db(self._db, self._config.download_dir)]
Exemple #6
0
    def get_podcasts(self):
        """Get a list of Podcast objects

        Returns all the subscribed podcasts from gPodder.
        """
        return [Podcast(p, self) for p in PodcastChannel.load_from_db(self._db, self._config.download_dir)]