def eraseMultipleRecording(self, cable_box, content_obj, is_recorded): if not cable_box.recordable: raise errors.RecordingError("Box ({}) not recordable".format( cable_box.name)) callsign = content_obj.callsign channel_number = content_obj.channel_number start = utils.genRecordRequestTime(content_obj.start_time) end = utils.genRecordRequestTime(content_obj.end_time) payload = { "request_type": "ERASE_MULTIPLE_RECORDING", "optimum_id": self.optimum_ID, "deviceType": self.device_type, "os": self.device_os, "AuthToken": self.AuthToken, "wifiRSSI": "NA", "home_id": self.home_ID, "serial_number": cable_box.serial, "hubId": self.hub_ID, "isRecorded": is_recorded, "program1": callsign + "|" + channel_number + "|" + start + "|" + end } conn = requests.get(base_url.dvr_req, params=payload) if conn.status_code == 200: xml_dom = minidom.parseString(conn.text) code = xml_dom.getElementsByTagName("Code")[0].childNodes[0].data if code != "0": message = xml_dom.getElementsByTagName( "Message")[0].childNodes[0].data raise ValueError("({}) {}".format(code, message)) return True return False
def _check_path(self, path): """Check if the destination path exists and we are allowed to write there. Args: path(string): A recording destination path. """ self.mountpoint = utils.filesystem.get_mount_point(self.drive) self.drive_monitor = drive_manager.DRIVE_MANAGER.get_drive_monitor_for_path(self.drive) if not self.drive_monitor or not self.drive_monitor.is_Ok(): raise errors.RecordingError("Can't start recording with given path {}.".format(path)) if not os.path.exists(path): try: os.makedirs(path) except: raise errors.RecordingError("Can't start recording with given path {}.".format(path))
def stop_recording(self): """Stop recording the rtmp inputs """ results = recorder.stop().result() success = True for val in results: success = success and (not results[val]) if not success: raise errors.RecordingError('Stoppping recording inputs failed') self.recording_status = RecordingStatus.Stopped
def start_recording(self, drives): """Start recording the rtmp inputs """ results = recorder.start().result() logging.info(results) success = True for val in results: success = success and results[val] if not success: raise errors.RecordingError('Starting recording inputs failed') self.recording_status = RecordingStatus.Started
def requestSeriesRecording(self, cable_box, content_obj, stop_time, save_days, save_episodes, all_episodes, quality, validate=True): if not cable_box.recordable: raise errors.RecordingError("Box ({}) not recordable".format( cable_box.name)) start_time = utils.genRecordRequestTime(content_obj.start) show_end_time = utils.genRecordRequestTime(content_obj.end) end_time = utils.addSeconds(content_obj.end, stop_time) end_time = utils.genRecordRequestTime(end_time) payload = { "request_type": "REQUEST_RECORDING", "optimum_id": self.optimum_ID, "deviceId": self.device_ID, "deviceType": self.device_type, "os": self.device_os, "AuthToken": self.AuthToken, "wifiRSSI": "NA", "home_id": self.home_ID, "serial_number": cable_box.serial, "hubId": self.hub_ID, "rec_type": "0", "channel_num": content_obj.channel_number, "call_sign": content_obj.channel_name, "start_time": start_time, "end_time": end_time, "showEndTime": show_end_time, "saveDays": save_days, "tribuneId": content_obj.tribune_ID, "save_episodes": save_episodes, "all_episodes": all_episodes, "quality": quality } conn = requests.get(base_url.dvr_req, params=payload) if conn.status_code == 200: return True else: return False
def getScheduledRecordings(self, cable_box): if not cable_box.recordable: raise errors.RecordingError("Box ({}) not recordable".format( cable_box.name)) payload = { "request_type": "GET_SCHEDULED_RECORDINGS", "optimum_id": self.optimum_ID, "deviceId": self.device_ID, "deviceType": self.device_type, "os": self.device_os, "AuthToken": self.AuthToken, "home_id": self.home_ID, "serial_number": cable_box.serial, "hubId": self.hub_ID, "wifiRSSI": "NA" } conn = requests.get(base_url.dvr_req, params=payload) if conn.status_code == 200: scheduled_data = json.loads(conn.text) code = scheduled_data['error'][0]['StatusCode'] if code != 0: message = scheduled_data['error'][0]['StatusDescription'] raise ValueError("({}) {}".format(code, message)) content = [] for program in scheduled_data['result']['SchProgMap']: title = program['SchProgElement']['Title'] description = program['SchProgElement']['LongDescription'] genres = program['SchProgElement']['Program']['Genres'] end_time = program['SchProgElement']['Program']['EndTime'] tv_rating = program['SchProgElement']['Program']['TVRatings'] sub_rating = program['SchProgElement']['Program'][ 'TVSubRating'] MPAA_rating = program['SchProgElement']['Program'][ 'MPAARatings'] critic_rating = program['SchProgElement']['Program'][ 'CriticRating'] release_date = program['SchProgElement']['Program'][ 'ReleaseDate'] callsign = program['SchProgElement']['Program']['callsign'] channel_number = program['SchProgElement']['Program'][ 'ChannelNumber'] start_time = program['SchProgElement']['Program']['StartTime'] tribune_ID = program['SchProgElement']['Program']['tribid'] try: episode_title = program['SchProgElement']['Program'][ 'EpisodeTitle'] except KeyError: episode_title = None try: episode_number = program['SchProgElement']['Program'][ 'EpisodeNumber'] except KeyError: episode_number = None try: season_number = program['SchProgElement']['Program'][ 'SeasonNumber'] except KeyError: season_number = None qualifiers = program['SchProgElement']['Program']['Qualifiers'] try: cast = program['SchProgElement']['Program']['Cast'] except KeyError: cast = None new_content = ScheduledContent( title, description, genres, end_time, tv_rating, sub_rating, MPAA_rating, critic_rating, release_date, callsign, channel_number, start_time, tribune_ID, episode_title, episode_number, season_number, qualifiers, cast) content.append(new_content) return content # TODO return better data return False
def getRecordedPrograms(self, cable_box): # try to fit in Content obj # holy f**k object is enourmous # results are JSON # need to return more data, dont pick and choose? if not cable_box.recordable: raise errors.RecordingError("Box ({}) not recordable".format( cable_box.name)) payload = { "request_type": "GET_RECORDED_PROGRAMS", "optimum_id": self.optimum_ID, "deviceId": self.device_ID, "deviceType": self.device_type, "os": self.device_os, "AuthToken": self.AuthToken, "home_id": self.home_ID, "serial_number": cable_box.serial, "hubId": self.hub_ID, "wifiRSSI": "NA" } conn = requests.get(base_url.dvr_req, params=payload) if conn.status_code == 200: rec_data = json.loads(conn.text) code = rec_data['error'][0]['StatusCode'] if code != 0: message = rec_data['error'][0]['StatusDescription'] raise ValueError("({}) {}".format(code, message)) recorded_dict = {} for program in rec_data['result']['RecordedProgList']: title = program['RecordedProgElement']['Title'] num_episodes = program['RecordedProgElement']['NumOfEpisodes'] try: save_days = program['RecordedProgElement']['SaveDays'] except KeyError: save_days = None description = program['RecordedProgElement']['LongDescription'] genres = program['RecordedProgElement']['Program']['Genres'] end_time = program['RecordedProgElement']['Program']['EndTime'] tv_rating = program['RecordedProgElement']['Program'][ 'TVRatings'] sub_rating = program['RecordedProgElement']['Program'][ 'TVSubRating'] MPAA_rating = program['RecordedProgElement']['Program'][ 'MPAARatings'] critic_rating = program['RecordedProgElement']['Program'][ 'CriticRating'] release_date = program['RecordedProgElement']['Program'][ 'ReleaseDate'] callsign = program['RecordedProgElement']['Program'][ 'callsign'] channel_number = program['RecordedProgElement']['Program'][ 'ChannelNumber'] start_time = program['RecordedProgElement']['Program'][ 'StartTime'] tribune_id = program['RecordedProgElement']['Program'][ 'tribid'] try: episode_title = program['RecordedProgElement']['Program'][ 'EpisodeTitle'] except KeyError: episode_title = None try: episode_number = program['RecordedProgElement']['Program'][ 'EpisodeNumber'] except KeyError: episode_number = None try: season_number = program['RecordedProgElement']['Program'][ 'SeasonNumber'] except KeyError: season_number = None qualifiers = program['RecordedProgElement']['Program'][ 'Qualifiers'] try: cast = program['RecordedProgElement']['Program']['Cast'] except KeyError: cast = None return True # TODO return some data return False