def _filter_programID(self, json): programs = list() count = self._MAX_REQUESTS episodes = dict() for station in json: for program in station['programs']: if count > 0: # TODO: HIGH Find way to map keys to one another so that # mapping isn't hard coded and can be reused. episode = dict() # Required fields # TODO: MID Construct hashing system to allow for application of obvious # filters such as by channel, time, genre, etc. episode['contenttype'] = "episode" episode['channelID'] = station['stationID'] episode['programID'] = program['programID'] episode['channel_md5'] = program['md5'] # Optional fields episode['length'] = HELPER.value(program, 'duration') episode['audioProperties'] = HELPER.value(program, 'audioProperties') episode['videoProperties'] = HELPER.value(program, 'videoProperties') #episode['new'] = program['new'] or "None" episode['releasedate'] = HELPER.value(program, 'airDateTime') episodes[program['programID']] = episode # Process program for next request programs.append(program['programID']) count -= 1 else: break # TODO: HIGH Append to episode object return ( episodes, programs )
def _adapter_episodes(self, json): episodes = dict() count = 5 for ep in json: # TODO: Remove if False stmt. DEBUG purposes if False: #count >= 1: count -= 1 print(ep['descriptions']) episode = dict() keys = ['titles', 0, 'title'] title = HELPER.getvalue(ep, keys, verbatim=False) keys = ['episodetitle'] eptitle = HELPER.getvalue(ep, keys, verbatim=False) episode['title'] = title episode['type'] = HELPER.value(ep, 'eventDetails') keys = ['descriptions', 'description', 0] description = HELPER.getvalue(ep, keys, verbatim=False) if description is not None: episode['description'] = HELPER.value(description, 'description') else: episode['description'] = "None" episode['shortdescriptionline1'] = eptitle snum = HELPER.getvalue(ep, ['metadata', 0, 'Gracenote', 'season'], verbatim=False) epnum = HELPER.getvalue(ep, ['metadata', 0, 'Gracenote', 'episode'], verbatim=False) episode['releasedate'] = HELPER.value(ep, 'originalAirDate') episode['actors'] = list() if HELPER.has_key(ep, 'cast'): for actor in ep['cast']: episode['actors'].append(actor['name']) if HELPER.has_key(ep, 'crew'): episode['director'] = ep['crew'][0]['name'] if HELPER.has_key(ep, 'hasImageArtwork'): episode['hasimageartwork'] = ep['hasImageArtwork'] episode['episode_md5'] = ep['md5'] episodes[ep['programID']] = episode return episodes