예제 #1
0
    def _concatenate_videos(self, episodes):
        episodes = self._get_sorted_episode_list(episodes)

        # TODO: Show file list dialog for reordering

        out_filename = self._get_save_filename()
        if out_filename is None:
            return

        list_filename = os.path.join(os.path.dirname(out_filename),
                '.' + os.path.splitext(os.path.basename(out_filename))[0] + '.txt')

        with open(list_filename, 'w') as fp:
            fp.write('\n'.join("file '%s'\n" % episode.local_filename(create=False)
                for episode in episodes))

        indicator = ProgressIndicator(_('Concatenating video files'),
                _('Writing %(filename)s') % {
                    'filename': os.path.basename(out_filename)
                }, False, self.gpodder.get_dialog_parent())

        def convert():
            ffmpeg = util.Popen(['ffmpeg', '-f', 'concat', '-nostdin', '-y',
                                 '-i', list_filename, '-c', 'copy', out_filename],
                                close_fds=True)
            result = ffmpeg.wait()
            util.delete_file(list_filename)
            util.idle_add(lambda: indicator.on_finished())
            util.idle_add(lambda: self.gpodder.show_message(
                _('Videos successfully converted') if result == 0 else
                _('Error converting videos'),
                _('Concatenation result'), important=True))

        util.run_in_background(convert, True)
예제 #2
0
    def obtain_podcasts_with(self, callback):
        if self.podcasts_progress_indicator is not None:
            self.podcasts_progress_indicator.on_finished()

        self.podcasts_progress_indicator = ProgressIndicator(
            _('Loading podcasts'),
            _('Please wait while the podcast list is downloaded'),
            parent=self.main_window)

        original_provider = self.current_provider

        self.en_query.set_sensitive(False)
        self.bt_search.set_sensitive(False)
        self.tag_cloud.set_sensitive(False)
        self.podcasts_model.clear()

        @util.run_in_background
        def download_data():
            try:
                podcasts = callback()
            except Exception as e:
                logger.warn('Got exception while loading podcasts: %s', e)
                podcasts = []

            @util.idle_add
            def update_ui():
                if self.podcasts_progress_indicator is not None:
                    self.podcasts_progress_indicator.on_finished()
                    self.podcasts_progress_indicator = None

                if original_provider == self.current_provider:
                    self.podcasts_model.load(podcasts or [])
                else:
                    logger.warn('Ignoring update from old thread')

                self.en_query.set_sensitive(True)
                self.bt_search.set_sensitive(True)
                self.tag_cloud.set_sensitive(True)
                if self.en_query.get_realized():
                    self.en_query.grab_focus()