Exemplo n.º 1
0
    def __init__(self, name):
        self.shortname = name
        self.episodes = {}

        # the following properties will be populated dynamically
        self.genres = []
        self.showid = ''
        self.name = ''
        self.link = ''
        self.country = ''
        self.status = ''
        self.classification = ''
        self.started = 0
        self.ended = 0
        self.seasons = 0

        show = feeds.search(self.shortname, node='show', timeout=timeout)
        if not show:
            raise ShowNotFound(name)
        # dynamically mapping the xml tags to properties:
        for elem in show:
            if not elem.tag == 'seasons':  # we'll set this later
                # these properties should be ints
                if elem.tag in ('started', 'ended'):
                    self.__dict__[elem.tag] = int(elem.text)
                # these are fine as strings
                else:
                    self.__dict__[elem.tag] = elem.text
        self.genres = [g.text for g in show.find('genres')]

        # and now grabbing the episodes
        eplist = feeds.episode_list(self.showid, node='Episodelist', timeout=timeout)

        if not eplist:
            eplist = []

        # populating the episode list
        for season in eplist:
            try:
                snum = int(season.attrib['no'])
            except KeyError:
                pass  # TODO: adding handeling for specials and movies
                # bsp: http://www.tvrage.com/feeds/episode_list.php?sid=3519
            else:
                self.episodes[snum] = Season()
                for episode in season:
                    epnum = int(episode.find('seasonnum').text)
                    self.episodes[snum][epnum] = Episode(
                        self.name,
                        snum,
                        episode.find('airdate').text,
                        episode.find('title').text,
                        episode.find('link').text,
                        epnum,
                        episode.find('prodnum').text,
                    )
                if snum > 0:
                    self.seasons = max(snum, self.seasons)
        self.episodes[self.seasons].is_current = True
Exemplo n.º 2
0
    def __init__(self, name):
        self.shortname = name
        self.episodes = {}
        
        # the following properties will be populated dynamically
        self.genres = []
        self.showid = ''
        self.name = ''
        self.link = ''
        self.country = ''
        self.status = ''
        self.classification = ''
        self.started = 0
        self.ended = 0
        self.seasons = 0

        show = feeds.search(self.shortname, node='show')
        # dynamically mapping the xml tags to properties:
        for elem in show:
            # Don't set these yet
            if elem.tag in ('seasons', ):
                continue
            # these properties should be ints
            elif elem.tag in ('started', 'ended'):
                self.__dict__[elem.tag] = int(elem.text)
            # these are fine as strings
            else:
                self.__dict__[elem.tag] = elem.text
        self.genres = [g.text for g in show.find('genres')]

        # and now grabbing the episodes
        eplist = feeds.episode_list(self.showid, node='Episodelist')

        # populating the episode list
        for season in eplist:
            try:
                snum = int(season.attrib['no'])
            except KeyError:
                pass # TODO: adding handeling for specials and movies
                # bsp: http://www.tvrage.com/feeds/episode_list.php?sid=3519
            else:
                self.episodes[snum] = Season()
                for episode in season:
                    epnum = int(episode.find('seasonnum').text)
                    self.episodes[snum][epnum] = Episode(
                        self.name,
                        snum,
                        episode.find('airdate').text,
                        episode.find('title').text,
                        episode.find('link').text,
                        epnum,
                        episode.find('prodnum').text,
                    )
                if snum > 0:
                    self.seasons += 1
        
        self.episodes[self.seasons].is_current = True
Exemplo n.º 3
0
def search(showname):
    """returns a list of ShowInfo objects
    
    this class is kind of a wrapper around the following of tvrage's xml feeds:
    * http://services.tvrage.com/feeds/search.php?show=SHOWNAME
    """
    showinfo_list = []
        
    search = feeds.search(showname)
    
    if search is not None:
        for node in search:
            sid = int(node[0].text)
            showinfo_list.append(ShowInfo(sid))
    else:
        raise NoInternetConnectionAvailable
    
    
    return showinfo_list