def episodes_for_podcast(self, podcast,
                             sort_order=Podcast.SortOrder.NewestFirst):
        page = 1
        pages_left = True
        episodes = []
        while pages_left:
            params = {'page': page, 'sort': sort_order, 'uuid': podcast.uuid}
            response = self._session.post("https://play.pocketcasts.com"
                                          "/web/episodes/find_by_podcast.json",
                                          json=params)
            response.raise_for_status()

            json_response = response.json()
            for episode_json in json_response['result']['episodes']:
                episode = Episode._from_json(episode_json, podcast)
                # episode = episode_json
                episodes.append(episode)

            # we should never ever receive more episodes than specified
            # well, better be fault tolerant
            if(json_response['result']['total'] > len(episodes)):
                page = page + 1
            else:
                pages_left = False

        return episodes
    def starred_episodes(self):
        response = self._session.post("https://play.pocketcasts.com"
                                      "/web/episodes/"
                                      "starred_episodes.json")
        response.raise_for_status()

        episodes = []
        podcasts = {}
        for episode_json in response.json()['episodes']:
            podcast_uuid = episode_json['podcast_uuid']
            if podcast_uuid not in podcasts:
                podcasts[podcast_uuid] = self.podcast(podcast_uuid)
            episode = Episode._from_json(episode_json, podcasts[podcast_uuid])
            episodes.append(episode)
        return episodes