Exemplo n.º 1
0
    def getlocalseasons(self, id):
        '''
        @type id: str
        @rtype: list
        '''
        seasons = {}
        
        if self._storage.exists('shows/%s/en.xml' % id):
            data = self._storage.getdata('shows/%s/en.xml' % id)
            
            xml = QDomDocument()
            xml.setContent(data)
            
            episodes = xml.elementsByTagName('Episode')
            
            for episode in range(episodes.count()):
                seasonid = unicode(QString(episodes.at(episode).toElement().elementsByTagName('seasonid').at(0).childNodes().at(0).toText().data()))
                seasonnum = QString(episodes.at(episode).toElement().elementsByTagName('SeasonNumber').at(0).childNodes().at(0).toText().data()).toInt()
                
                if seasonnum[1]:
                    if seasonnum[0] > 0:
                        if not seasonid in seasons:
                            newseason = season()
                            newseason.id = seasonid
                            newseason.number = seasonnum[0]
                            newseason.image = 'seasonbanners/%s-%d.jpg' % (id, newseason.number)
                            
                            newseason.showid = id
                            
                            seasons[seasonid] = newseason

        return sorted(seasons.values(), key = lambda item: item.number)
Exemplo n.º 2
0
 def test_season(self):
     obj = season(u'a', u'b', 1, u'c', u'd', 2)
     self.assertEqual(obj.description, u'a', 'description is assigned incorrectly')
     self.assertEqual(obj.image, u'b', 'image is assigned incorrectly')
     self.assertEqual(obj.number, 1, 'number is assigned incorrectly')
     self.assertEqual(obj.id, u'c', 'id is assigned incorrectly')
     self.assertEqual(obj.showid, u'd', 'showid is assigned incorrectly')
     self.assertEqual(obj.data, 2, 'data is assigned incorrectly')
     
     self.assertRaises(exceptions.TypeError, season, (1, 1, '', 1, 1))