Exemplo n.º 1
0
def insert_many_queries(call_queries, text_queries, voicemail_queries):
    if len(call_queries) >= num_before_insert:
        Call.insert_many(call_queries).execute()
        # Remove all the stored ones
        del call_dict[:]
        print("Inserted " + str(num_before_insert) + " or more Calls")
    if len(text_queries) >= num_before_insert:
        for text_message in text_queries:
            Message.insert(text_message).execute()

        # Message.insert_many(text_queries).execute()
        del text_dict[:]
        print("Inserted " + str(num_before_insert) + " or more Texts")
    if len(voicemail_queries) >= num_before_insert:
        Voicemail.insert_many(voicemail_queries).execute()
        del voicemail_dict[:]
        print("Inserted " + str(num_before_insert) + " or more Voicemails")
Exemplo n.º 2
0
                            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)
Exemplo n.º 3
0
message_list = []
for conversation in conversations:
    #print(conversation.get_timestamp())
    print("conversation id: %s, participants: %s" % (conversation.get_id(), str(conversation.get_participants())))
    #print_conversation(conversation)
    # Need to save to the database
    for event in conversation.get_events():
        participants = conversation.get_participants()
        recievers = participants.get_recievers_id(event.get_sender_id())
        list_of_recievers = str(recievers)
        event_type = event.get_type()
        message = str(event.get_formatted_message())
        sender = participants.get_by_id(event.get_sender_id())
        sender_name = str(sender)
        if str(event_type) == "VOICEMAIL":
            Voicemail.insert({'date': event.get_timestamp(), 'caller': sender_name,
                              'message': message}).execute()
        elif str(event_type) == "SMS":
            Message.insert({'date': event.get_timestamp(), 'type': 'sms',
                        'sender': sender_name, 'reciever': list_of_recievers,
                        'message': message}).execute()
        elif str(event_type) == "REGULAR_CHAT_MESSAGE":
            Message.insert({'date': event.get_timestamp(), 'type': 'hangouts',
                            'sender': sender_name, 'reciever': list_of_recievers,
                            'message': message}).execute()
        else:
            print("Event Type not Recognized: " + str(event_type))