'key': 'org', 'value': '', 'title': 'Organisation' }, { 'type': 'text', 'key': 'num', 'value': output, 'title': 'Number' }, { 'type': 'text', 'key': 'note', 'value': 'Added by Make Call script on ' + datetime.datetime.now().ctime(), 'title': 'Notes' }] fields = dialogs.form_dialog('Add a Contact', fields) newContact = contacts.Person() newContact.note = fields['note'] newContact.first_name = fields['first'] newContact.last_name = fields['last'] newContact.organization = fields['org'] newContact.phone = [(contacts.WORK, fields['num'])] contacts.add_person(newContact) contacts.save() # Call the number webbrowser.open('tel:' + urllib.quote(output))
# https://gist.github.com/my4paws/ae7dc32ba9937996d4d13848ab13404c # https://forum.omz-software.com/topic/4821/add-contact-to-a-group import contacts import clipboard import webbrowser import dateutil name = clipboard.get().split(',') pers = contacts.Person() grp = contacts.Group() pers.first_name = name[0] pers.last_name = name[1] pers.middle_name = name[2] pers.prefix = name[3] pers.job_title = name[4] pers.department = name[5] pers.email = [(contacts.HOME, name[6])] pers.address = [(contacts.HOME, { contacts.STREET: name[7], contacts.CITY: name[8], contacts.STATE: name[9], contacts.ZIP: name[10], contacts.COUNTRY: name[11] })] pers.nickname = name[13] pers.organization = name[14] pers.phone = [(contacts.HOME, name[15]), (contacts.IPHONE, name[16]), (contacts.WORK, name[17])] from dateutil import parser string_date = parser.parse(name[18])
def convertdate(date): date = date.split('.') if len(date) == 2: return datetime.datetime.combine( datetime.date(1604, int(date[1]), int(date[0])), datetime.time(0, 0)) else: return datetime.datetime.combine( datetime.date(int(date[2]), int(date[1]), int(date[0])), datetime.time(0, 0)) a = vkapi.friends.get(fields='contacts,bdate') a = a['items'] for i in a: Temp = contacts.Person() Temp.last_name = i['last_name'] Temp.first_name = i['first_name'] if 'mobile_phone' in i.keys(): try: Temp.phone = [('mobile', i['mobile_phone'])] except: pass if 'home_phone' in i.keys(): try: Temp.phone.append(('home', i['home_phone'])) except: pass Temp.url = [('vk', 'http://vk.com/id' + str(i['id']))] if 'bdate' in i.keys(): Temp.birthday = convertdate(i['bdate'])