Exemple #1
0
def get_last_episodes(tvshow_id, hd=False):
    """
    Returns the list with most recent episodes for the given tvshow  available
    in show RSS website. The list returned does not specify any specific order.

    :param tvshow_id: id of the tv show to get the episodes from.
    :param hd: if true it will be returned the HD version of the episodes.
    :raises RSSFormatError: if the rssfeed returned by the show rss is incorrect
    """
    try:
        try:
            # get to the channel element
            root = ElementTree.fromstring(read_rssfeed(tvshow_id))
            channel = root.find("channel")
        except ElementTree.ParseError as parse_error:
            raise RSSFormatError(parse_error.msg)

        episodes = [
            Episode.from_string(item.find("title").text, item.find("link").text) for item in channel.findall("item")
        ]

        # TODO include HD episodes
        # remove HD episodes
        episodes = [episode for episode in episodes if not episode.hd]

    except AttributeError:
        # one of the necessary elements was not provided
        raise RSSFormatError()

    return episodes
 def test_from_string_raise_exception(self, complete_title,
                                      exception_expected):
     with pytest.raises(exception_expected):
         Episode.from_string(complete_title, self.link)
 def test_from_string(self, complete_title, expected):
     assert Episode.from_string(complete_title, self.link) == expected