add possibility to add to black list
This commit is contained in:
@@ -11,7 +11,7 @@ from src.utils.excel_reader import read_contacts, fr_phone_number_prefix, get_ra
|
||||
|
||||
|
||||
def upload_contacts_list():
|
||||
_contacts_to_book = read_contacts("/Users/lpan/Desktop/contact_list_2024-09-25.xlsx")
|
||||
_contacts_to_book = read_contacts("/Users/lpan/Desktop/contact_list_2024-09-27_today.xlsx")
|
||||
return _contacts_to_book
|
||||
|
||||
|
||||
@@ -143,15 +143,16 @@ def write_to_black_list(contacts: list):
|
||||
MONGO_STORE_MANAGER.insert_blacklist_contact(contact)
|
||||
|
||||
|
||||
def get_contact_list_not_received_mail():
|
||||
def update_contact_list_not_received_mail():
|
||||
_contact_list = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
|
||||
for _contact in _contact_list:
|
||||
if not _contact.url_validated:
|
||||
write_to_black_list([_contact])
|
||||
|
||||
|
||||
def get_old_validated_contact_list(remove_blacklisted_contact=True):
|
||||
_valid_contact_list = MONGO_STORE_MANAGER.get_all_successful_items_for_one_day("2024-09-10")
|
||||
def get_old_validated_contact_list(remove_blacklisted_contact=True, _day_in_str="2024-09-09"):
|
||||
_valid_contact_list = MONGO_STORE_MANAGER.get_all_successful_items_for_one_day(_day_in_str)
|
||||
_domain_list_to_remove = ["firemail.de", "onet.pl", "yahoo.com", "gmx.com"]
|
||||
_all_contacts = MONGO_STORE_MANAGER.get_all_contacts_to_book()
|
||||
_contact_to_save = []
|
||||
for _contact in _valid_contact_list:
|
||||
@@ -177,23 +178,30 @@ def get_old_validated_contact_list(remove_blacklisted_contact=True):
|
||||
and _added_item.first_name == _contact.first_name):
|
||||
_need_to_save = False
|
||||
if _need_to_save:
|
||||
# remove the contact if domain is not in the list
|
||||
if _contact.mail.split("@")[1] not in _domain_list_to_remove:
|
||||
_contact_to_save.append(_contact)
|
||||
# remove blacklisted contact if needed
|
||||
if remove_blacklisted_contact:
|
||||
_blacklisted_contact = MONGO_STORE_MANAGER.get_blacklist_contacts()
|
||||
_list_without_blacklisted = [contact for contact in _contact_to_save if
|
||||
contact.mail not in [bl.mail for bl in _blacklisted_contact]]
|
||||
write_new_contacts_to_excel(_list_without_blacklisted, file_name=_day_in_str + "_without_blacklisted")
|
||||
_contact_to_save_list = _contact_to_save
|
||||
write_new_contacts_to_excel(_contact_to_save_list)
|
||||
write_new_contacts_to_excel(_contact_to_save_list, file_name=_day_in_str)
|
||||
|
||||
|
||||
# 把新的联系人存到网上
|
||||
if __name__ == '__main__':
|
||||
# contacts_to_book = upload_contacts_list()
|
||||
# MONGO_STORE_MANAGER.upload_contact_list(contacts_to_book)
|
||||
contacts_to_book = upload_contacts_list()
|
||||
MONGO_STORE_MANAGER.upload_contact_list(contacts_to_book)
|
||||
# print("start at {}".format(datetime.datetime.now()))
|
||||
# generate_valid_contact_list_for_day(segment_number=2)
|
||||
# generate_contact_from_mail_list("/Users/lpan/Downloads/邮箱及密码.xlsx")
|
||||
# print("end at {}".format(datetime.datetime.now()))
|
||||
# get_contact_list_not_received_mail()
|
||||
# update_contact_list_not_received_mail()
|
||||
# generate_valid_contact_list_for_day(segment_number=2)
|
||||
get_old_validated_contact_list()
|
||||
# generate_contact_from_mail_list("/Users/lpan/Downloads/邮箱及密码.xlsx")
|
||||
# get_old_validated_contact_list()
|
||||
# print("end at {}".format(datetime.datetime.now()))
|
||||
# generate_all_contact_list()
|
||||
# merge_contact_list_files(
|
||||
|
||||
Reference in New Issue
Block a user