text = voicemail.find_all("span", {"class": "full-text"})[0].text # Voicemail length if len(voicemail.find_all("abbr", {"class": "duration"})) >= 1: duration = voicemail.find_all("abbr", {"class": "duration"})[0].text yaml_data.append( { "type": "voicemail", "time": date_string, "caller": caller, "duration": duration, "phone number": phone_number[1], "message": text, } ) voicemail2SQLite(caller=caller, number=phone_number[1], time=date_string, message=text) yaml_array = yaml.dump(yaml_data, yaml_output, default_flow_style=False) ################################################################### # # End of Voicemail to yaml script # ################################################################### # Insert any remaining entries if len(call_dict) != 0: Call.insert_many(call_dict) if len(text_dict) != 0: Message.insert_many(text_dict) if len(voicemail_dict) != 0: Voicemail.insert_many(voicemail_dict)