def picture_upload_thread(url, filename, headers): with open(filename, 'rb') as picture: picture_data = picture.read() log.debug('Uploading picture') r = requests.post(url, data=picture_data, headers=headers) if r.status_code != 200: raise KikApiException(r.status_code)
def __init__(self, data: BeautifulSoup): if 'jid' not in data.attrs: raise KikApiException("No jid in group xml") super().__init__(data['jid']) self.members = [GroupMember(m) for m in data.findAll('m')] self.code = data.code.text if data.code else None self.pic = data.pic.text if data.pic else None self.name = data.n.text if data.n else None self.is_public = 'is-public' in data and data['is-public'] == "true"
def __init__(self, data: BeautifulSoup): if 'jid' not in data.attrs: raise KikApiException("No jid in user xml {}".format(data)) super().__init__(data['jid']) self.username = data.username.text if data.username else None self.display_name = data.find('display-name').text if data.find( 'display-name') else None self.pic = data.pic.text if data.pic else None self.verified = True if data.verified else False
def send(url, filename, jid, username, password): password_key = CryptographicUtils.key_from_password(username, password) if not os.path.isfile(filename): raise KikApiException("File doesn't exist") headers = { 'x-kik-jid': jid, 'x-kik-password': password_key, 'User-Agent': 'Kik/13.0.0.7521 (Android 7.1.2) Dalvik/2.1.0 (Linux; U; Android 7.1.2; Nexus 7 Build/NJH47F)', } Thread(target=picture_upload_thread, args=(url, filename, headers), name='KikProfilepics').start()
def __init__(self, xml_data: BeautifulSoup): if 'jid' not in xml_data.attrs: raise KikApiException("No jid in group xml") super().__init__(xml_data['jid']) self.members = [GroupMember(m) for m in xml_data.findAll('m')] self.owner = [ m.text for m in xml_data.findAll('m') if GroupMember(m).is_owner ] self.admins = [ m.text for m in xml_data.findAll('m') if GroupMember(m).is_admin ] self.banned_members = [GroupMember(m) for m in xml_data.findAll('b')] self.code = xml_data.code.text if xml_data.code else None self.pic = xml_data.pic.text if xml_data.pic else None self.name = xml_data.n.text if xml_data.n else None self.is_public = xml_data.get('is-public') == "true"