def get_meetings(self, meta=False): """ This call will return a list of all the meetings found on this server. """ call = 'getMeetings' query = urlencode((('random', 'random'), )) xml = yield get_xml(self.bbb_api_url, self.salt, call, query) if xml is not None: # Create dict of values for easy use in template all_meetings = [] meetings = xml[1].findall('meeting') for meeting in meetings: meeting_id = meeting.find('meetingID').text password = meeting.find('moderatorPW').text info = yield self.meeting_info(meeting_id, password, meta=meta) all_meetings.append({ 'name': meeting_id, 'moderator_pw': password, 'attendee_pw': meeting.find('attendeePW').text, 'has_been_forcibly_ended': meeting.\ find('hasBeenForciblyEnded').text == "true", 'running': meeting.find('running').text == "true", 'create_time': int(meeting.find('createTime').text), 'info': info }) defer.returnValue(all_meetings) else: defer.returnValue(None)
def check_api(self): """ This call simply checks whether a bigbluebutton instane is reachable. """ xml = yield get_xml(self.bbb_api_url, self.salt, None, None) defer.returnValue(xml)
def get_meetings(self, meta=False): """ This call will return a list of all the meetings found on this server. """ call = 'getMeetings' query = urlencode(( ('random', 'random'), )) xml = yield get_xml(self.bbb_api_url, self.salt, call, query) if xml is not None: # Create dict of values for easy use in template all_meetings = [] meetings = xml[1].findall('meeting') for meeting in meetings: meeting_id = meeting.find('meetingID').text password = meeting.find('moderatorPW').text info = yield self.meeting_info(meeting_id, password, meta=meta) all_meetings.append({ 'name': meeting_id, 'moderator_pw': password, 'attendee_pw': meeting.find('attendeePW').text, 'has_been_forcibly_ended': meeting.\ find('hasBeenForciblyEnded').text == "true", 'running': meeting.find('running').text == "true", 'create_time': int(meeting.find('createTime').text), 'info': info }) defer.returnValue(all_meetings) else: defer.returnValue(None)
def check_api(self): """ This call simply checks whether a bigbluebutton instane is reachable. """ xml = yield get_xml(self.bbb_api_url, self.salt, None, None) defer.returnValue(xml)
def meeting_info(self, meeting_id, password, meta=False): """ This call will return all of a meeting's information, including the list of attendees as well as start and end times. :param meetingID: The meeting ID that identifies the meeting :param password: The moderator password for this meeting. """ call = 'getMeetingInfo' query = urlencode(( ('meetingID', meeting_id), ('password', password), )) xml = yield get_xml(self.bbb_api_url, self.salt, call, query) if xml is not None: # Create dict of values for easy use in template users = [] attendees = xml.find('attendees') if attendees is not None: for attendee in attendees.getchildren(): user = {} user['user_id'] = attendee.find('userID').text user['name'] = attendee.find('fullName').text user['role'] = attendee.find('role').text users.append(user) metadata_dict = {} if meta: metadata = xml.find('metadata') for data in list(metadata): metadata_dict[data.tag] = decode_json(data.text) meeting_info = { 'meeting_name': xml.find('meetingName').text, 'meeting_id': xml.find('meetingID').text, 'create_time': int(xml.find('createTime').text), 'voice_bridge': int(xml.find('voiceBridge').text), 'attendee_pw': xml.find('attendeePW').text, 'moderator_pw': xml.find('moderatorPW').text, 'running': xml.find('running').text == "true", 'recording': xml.find('recording').text == "true", 'has_been_forcibly_ended': xml.\ find('hasBeenForciblyEnded').text == "true", 'start_time': int(xml.find('startTime').text), 'end_time': int(xml.find('endTime').text), 'participant_count': int(xml.find('participantCount').text), 'max_users': int(xml.find('maxUsers').text), 'moderator_count': int(xml.find('moderatorCount').text), 'users': users } if meta and metadata_dict: meeting_info.update(metadata_dict) defer.returnValue(meeting_info) else: defer.returnValue(None)
def meeting_info(self, meeting_id, password, meta=False): """ This call will return all of a meeting's information, including the list of attendees as well as start and end times. :param meetingID: The meeting ID that identifies the meeting :param password: The moderator password for this meeting. """ call = 'getMeetingInfo' query = urlencode(( ('meetingID', meeting_id), ('password', password), )) xml = yield get_xml(self.bbb_api_url, self.salt, call, query) if xml is not None: # Create dict of values for easy use in template users = [] attendees = xml.find('attendees') if attendees is not None: for attendee in attendees.getchildren(): user = {} user['user_id'] = attendee.find('userID').text user['name'] = attendee.find('fullName').text user['role'] = attendee.find('role').text users.append(user) metadata_dict = {} if meta: metadata = xml.find('metadata') for data in list(metadata): metadata_dict[data.tag] = decode_json(data.text) meeting_info = { 'meeting_name': xml.find('meetingName').text, 'meeting_id': xml.find('meetingID').text, 'create_time': int(xml.find('createTime').text), 'voice_bridge': int(xml.find('voiceBridge').text), 'attendee_pw': xml.find('attendeePW').text, 'moderator_pw': xml.find('moderatorPW').text, 'running': xml.find('running').text == "true", 'recording': xml.find('recording').text == "true", 'has_been_forcibly_ended': xml.\ find('hasBeenForciblyEnded').text == "true", 'start_time': int(xml.find('startTime').text), 'end_time': int(xml.find('endTime').text), 'participant_count': int(xml.find('participantCount').text), 'max_users': int(xml.find('maxUsers').text), 'moderator_count': int(xml.find('moderatorCount').text), 'users': users } if meta and metadata_dict: meeting_info.update(metadata_dict) defer.returnValue(meeting_info) else: defer.returnValue(None)
def is_running(self, meeting_id): """ This call enables you to simply check on whether or not a meeting is running by looking it up with your meeting ID. :param meeting_id: ID that can be used to identify the meeting """ call = 'isMeetingRunning' match = 'running' query = urlencode((('meetingID', meeting_id), )) xml = yield get_xml(self.bbb_api_url, self.salt, call, query) defer.returnValue(xml_match(xml, match))
def delete_recordings(self, record_id, publish=False): """ Delete one or more recordings for a given recordID (or set of record IDs). :param record_id: A record ID for specify the recordings to delete. It can be a set of meetingIDs separate by commas. :param publish: The value for publish or unpublish the recording(s). Available values: True or False. """ call = 'deleteRecordings' match = "deleted" query = urlencode( (('recordID', record_id), 'publish', str(publish).lower())) xml = yield get_xml(self.bbb_api_url, self.salt, call, query) defer.returnValue(xml_match(xml, match))
def is_running(self, meeting_id): """ This call enables you to simply check on whether or not a meeting is running by looking it up with your meeting ID. :param meeting_id: ID that can be used to identify the meeting """ call = 'isMeetingRunning' match = 'running' query = urlencode(( ('meetingID', meeting_id), )) xml = yield get_xml(self.bbb_api_url, self.salt, call, query) defer.returnValue(xml_match(xml, match))
def get_recordings(self, meeting_id=u'', meta=None): """ Retrieves the recordings that are available for playback for a given meetingID (or set of meeting IDs). :param meetingID: The meeting ID that identifies the meeting :param meta: You can pass one or more metadata values to filter the recordings returned """ call = 'getRecordings' params = {} if meeting_id: params.update(dict(meetingID=meeting_id)) if meta: for k, v in meta.iteritems(): meta_key = "meta_%s" % k params.update({meta_key: json.dumps(v)}) if params: query = urlencode((params)) else: query = '' xml = yield get_xml(self.bbb_api_url, self.salt, call, query) # ToDO implement more keys if xml is not None: recordings = xml.find('recordings') records = [] for meeting in list(recordings): record = {} record['record_id'] = meeting.find('recordID').text record['meeting_id'] = meeting.find('meetingID').text record['meeting_name'] = meeting.find('name').text record['published'] = meeting.find('published').text == "true" record['start_time'] = meeting.find('startTime').text record['name'] = meeting.find('name').text record['end_time'] = meeting.find('endTime').text metadata = meeting.find('metadata') if metadata is not None: for data in list(metadata): record[data.tag] = decode_json(data.text) size = meeting.find('size') if size is not None: record['size'] = meeting.find('size').text playback = meeting.find('playback') play_format = playback.find('format') record['length'] = play_format.find('length').text record['url'] = play_format.find('url').text records.append(record) defer.returnValue(records) else: defer.returnValue(None)
def get_recordings(self, meeting_id=u'', meta=None): """ Retrieves the recordings that are available for playback for a given meetingID (or set of meeting IDs). :param meetingID: The meeting ID that identifies the meeting :param meta: You can pass one or more metadata values to filter the recordings returned """ call = 'getRecordings' params = {} if meeting_id: params.update(dict(meetingID=meeting_id)) if meta: for k, v in meta.iteritems(): meta_key = "meta_%s" % k params.update({meta_key: json.dumps(v)}) if params: query = urlencode((params)) else: query = '' xml = yield get_xml(self.bbb_api_url, self.salt, call, query) # ToDO implement more keys if xml is not None: recordings = xml.find('recordings') records = [] for meeting in list(recordings): record = {} record['record_id'] = meeting.find('recordID').text record['meeting_id'] = meeting.find('meetingID').text record['meeting_name'] = meeting.find('name').text record['published'] = meeting.find('published').text == "true" record['start_time'] = meeting.find('startTime').text record['name'] = meeting.find('name').text record['end_time'] = meeting.find('endTime').text metadata = meeting.find('metadata') if metadata is not None: for data in list(metadata): record[data.tag] = decode_json(data.text) size = meeting.find('size') if size is not None: record['size'] = meeting.find('size').text playback = meeting.find('playback') play_format = playback.find('format') record['length'] = play_format.find('length').text record['url'] = play_format.find('url').text records.append(record) defer.returnValue(records) else: defer.returnValue(None)
def create_meeting(self): """ creates the meeting """ meeting = Meeting(self.bbb_api_url, self.salt) is_running = yield meeting.is_running(self.meeting_id) if not is_running: call = 'create' if self.pre_upload_slide is not None: self.welcome = ( 'The presentation will appear in moment. To download click <a href="%(url)s"></a>.' '<br> %(welcome)s' % { "url": self.pre_upload_slide, "welcome": self.welcome }) if not self.voice_bridge: voicebridge = 70000 + random.randint(0, 9999) else: voicebridge = self.voice_bridge params = dict( name=self.meeting_name, meetingID=self.meeting_id, attendeePW=self.attendee_password, moderatorPW=self.moderator_password, voiceBridge=voicebridge, dialNumber=self.dial_number, welcome=self.welcome, logoutURL=self.logout_url, maxParticipants=self.max_participants, duration=self.duration, record=self.record, moderatorOnlyMessage=self.moderator_only_message, autoStartRecording=self.auto_start_recording, allowStartStopRecording=self.allow_start_stop_recording) if self.meta: for k, v in self.meta.iteritems(): meta_key = "meta_%s" % k params.update({meta_key: json.dumps(v)}) query = urlencode((params)) xml = yield get_xml(self.bbb_api_url, self.salt, call, query, self.pre_upload_slide) if xml is not None: defer.returnValue(xml) else: defer.returnValue(None)
def delete_recordings(self, record_id, publish=False): """ Delete one or more recordings for a given recordID (or set of record IDs). :param record_id: A record ID for specify the recordings to delete. It can be a set of meetingIDs separate by commas. :param publish: The value for publish or unpublish the recording(s). Available values: True or False. """ call = 'deleteRecordings' match = "deleted" query = urlencode(( ('recordID', record_id), 'publish', str(publish).lower() )) xml = yield get_xml(self.bbb_api_url, self.salt, call, query) defer.returnValue(xml_match(xml, match))
def end_meeting(self, meeting_id, password): """ Use this to forcibly end a meeting and kick all participants out of the meeting. :param meetingID: The meeting ID that identifies the meeting you are attempting to end. :param password: The moderator password for this meeting. You can not end a meeting using the attendee password. """ call = 'end' query = urlencode(( ('meetingID', meeting_id), ('password', password), )) xml = yield get_xml(self.bbb_api_url, self.salt, call, query) if xml is not None: defer.returnValue(xml) else: defer.returnValue(None)
def end_meeting(self, meeting_id, password): """ Use this to forcibly end a meeting and kick all participants out of the meeting. :param meetingID: The meeting ID that identifies the meeting you are attempting to end. :param password: The moderator password for this meeting. You can not end a meeting using the attendee password. """ call = 'end' query = urlencode(( ('meetingID', meeting_id), ('password', password), )) xml = yield get_xml(self.bbb_api_url, self.salt, call, query) if xml is not None: defer.returnValue(xml) else: defer.returnValue(None)
def create_meeting(self): """ creates the meeting """ meeting = Meeting(self.bbb_api_url, self.salt) is_running = yield meeting.is_running(self.meeting_id) if not is_running: call = 'create' if self.pre_upload_slide is not None: self.welcome = ('The presentation will appear in moment. To download click <a href="%(url)s"></a>.' '<br> %(welcome)s' % {"url": self.pre_upload_slide, "welcome": self.welcome}) if not self.voice_bridge: voicebridge = 70000 + random.randint(0, 9999) else: voicebridge = self.voice_bridge params = dict(name=self.meeting_name, meetingID=self.meeting_id, attendeePW=self.attendee_password, moderatorPW=self.moderator_password, voiceBridge=voicebridge, dialNumber=self.dial_number, welcome=self.welcome, logoutURL=self.logout_url, maxParticipants=self.max_participants, duration=self.duration, record=self.record, moderatorOnlyMessage=self.moderator_only_message, autoStartRecording=self.auto_start_recording, allowStartStopRecording=self.allow_start_stop_recording) if self.meta: for k, v in self.meta.iteritems(): meta_key = "meta_%s" % k params.update({meta_key: json.dumps(v)}) query = urlencode((params)) xml = yield get_xml(self.bbb_api_url, self.salt, call, query, self.pre_upload_slide) if xml is not None: defer.returnValue(xml) else: defer.returnValue(None)