示例#1
0
    def generateShowsAndSave(self):
        f = open('../../xml/rteshows.json', 'w')
        for letter in 'H':
            for show in self.getShows(type='az', params='?id=%s'%(letter)):
                key = show['title']
                try:
                    showkeys = self.KNOWN_RTE_SHOWS[key].keys()

                    print 'Updating ' + show['title']
                    if not 'TVDBid' in showkeys or not 'IMDB_ID' in showkeys:
                        print 'Getting TVDBID and details'
                        if not 'TVDBName' in showkeys:
                            details = Util().getSeriesDetailsByName(show['title'])
                        else:
                            details = Util().getSeriesDetailsByName(self.KNOWN_RTE_SHOWS[key]['TVDBName'])

                        if not details is None:
                            self.KNOWN_RTE_SHOWS[key]['TVDBbanner'] = details['banner']
                            self.KNOWN_RTE_SHOWS[key]['TVDBid'] = details['id']
                            self.KNOWN_RTE_SHOWS[key]['IMDB_ID'] = details['IMDB_ID']
                    else:
                        print 'Getting Posters'
                        if not 'Fanart' in showkeys and not 'Poster' in showkeys:
                            details = Util().getDetailsForSerieByID(self.KNOWN_RTE_SHOWS[key]['title'], self.KNOWN_RTE_SHOWS[key]['TVDBid'])
                            if not details is None:
                                det_keys = details.keys()
                                if 'Fanart' in det_keys:
                                    self.KNOWN_RTE_SHOWS[key]['Fanart'] = details['Fanart']
                                if 'Poster' in det_keys:
                                    self.KNOWN_RTE_SHOWS[key]['Poster'] = details['Poster']
                                if 'Season' in det_keys:
                                    self.KNOWN_RTE_SHOWS[key]['Season'] = details['Season']

                except:
                    print 'Adding ' + show['title']

                    self.KNOWN_RTE_SHOWS[key] = {}
                    self.KNOWN_RTE_SHOWS[key]['title'] = show['title']
                    details = Util().getSeriesDetailsByName(show['title'])
                    if not details is None:
                        self.KNOWN_RTE_SHOWS[key]['TVDBbanner'] = details['banner']
                        self.KNOWN_RTE_SHOWS[key]['TVDBid'] = details['id']

                        print 'Getting Posters'
                        details = Util().getDetailsForSerieByID(self.KNOWN_RTE_SHOWS[key]['title'], self.KNOWN_RTE_SHOWS[key]['TVDBid'])
                        if not details is None:
                            det_keys = details.keys()
                            if 'Fanart' in det_keys:
                                self.KNOWN_RTE_SHOWS[key]['Fanart'] = details['Fanart']
                            if 'Poster' in det_keys:
                                self.KNOWN_RTE_SHOWS[key]['Poster'] = details['Poster']
                            if 'Season' in det_keys:
                                self.KNOWN_RTE_SHOWS[key]['Season'] = details['Season']

        S.dump(self.KNOWN_RTE_SHOWS, f, indent=4)
        f.close()
示例#2
0
    def getEpisodes(self, showID):
        # Login to Magnet Web TV
        opener = self.login(self.settings['magnet_username'], self.settings['magnet_password'])
        
        # Load and Decode JSON object
        req = urllib2.Request(NOWANDNEXT_URL)
        req.add_header('X-Forwarded-For', FORWARDED_FOR_IP)
        resp = opener.open(req)
        channels = S.loads(resp.read())
        resp.close()
        
        # Logout
        self.logout(opener)
        
        # Return the shows for this channel
        for channel in channels:
            if showID == str(channel['channel']['id']):
                for video in channel['videos']:
                    # Calculate Start time
                    x = video['startTime'] / 1000
                    start_seconds = x % 60
                    x /= 60
                    start_minutes = x % 60
                    x /= 60
                    start_hours = x % 24

                    # Calculate End Time
                    x = video['endTime'] / 1000
                    end_seconds = x % 60
                    x /= 60
                    end_minutes = x % 60
                    x /= 60
                    end_hours = x % 24
                    
                    showtime = "%02d:%02d-%02d:%02d" % (start_hours, start_minutes, end_hours, end_minutes)
                    
                    # 1800 -> 30mins
                    # 3000 -> 50mins
                    
                    title = self.convertHTML(video['name'])
                    
                    details = Util().getSeriesDetailsByName(title)
                    if details is None:
                        pic = LOGOICON
                    elif 'Poster' in details.keys():
                        pic = details['Poster']
                    elif 'Season' in details.keys():
                        pic = details['Season']
                    else:
                        pic = LOGOICON
                    
                    yield {'Channel'      : CHANNEL,
                            'Thumb'       : pic,
                            'url'         : str(video['id']),
                            'Title'       : "%s - %s" % (showtime, title),
                            'mode'        : MenuConstants.MODE_PLAYVIDEO,
                            'Plot'        : self.convertHTML(video['description']),
                            'plotoutline' : self.convertHTML(video['name']),
                            'Date'        : date.today().strftime("%d-%m-%Y"),
                            'Duration'    : str(video['duration']/60),
                            }