Beispiel #1
0
    def merge_states(self, episode, episode2):

        key = lambda x: x.user
        states1 = sorted(all_episode_states(self.episode1), key=key)
        states2 = sorted(all_episode_states(self.episode2), key=key)

        logger.info("Merging %d episode states of %s into %s", len(states2), episode2, episode)

        for state, state2 in utils.iterate_together([states1, states2], key):

            if state == state2:
                continue

            if state is None:
                self.actions["move-episode-state"] += 1
                update_episode_state_object(state2, self.episode1.podcast, self.episode1._id)

            elif state2 is None:
                continue

            else:
                esm = EpisodeStateMerger(state, state2, self.actions)
                esm.merge()
Beispiel #2
0
    def reassign_episodes(self, podcast1, podcast2):

        logger.info("Re-assigning episodes of %s into %s", podcast2, podcast1)

        # re-assign episodes to new podcast
        # if necessary, they will be merged later anyway
        for e in episodes_for_podcast_uncached(podcast2):
            self.actions["reassign-episode"] += 1

            for s in all_episode_states(e):
                self.actions["reassign-episode-state"] += 1

                update_episode_state_object(s, podcast1.get_id())

            self._save_episode(e=e, podcast1=podcast1)
Beispiel #3
0
    def add_podcast_recursive(self, podcast, docs):
        self.add_podcast(podcast, docs)

        progress(0, len(docs), podcast, stream=sys.stderr)

        states = all_podcast_states(podcast)
        for state in states:
            self.add_podcast_state(state, docs)
            progress(0, len(docs), state, stream=sys.stderr)

        # Episodes
        for episode in episodes_for_podcast(podcast.get_podcast()):
            self.add_episode(episode, docs)
            progress(0, len(docs), episode, stream=sys.stderr)

            states = all_episode_states(episode)
            for state in states:
                self.add_episode_state(state, docs)
                progress(0, len(docs), state, stream=sys.stderr)