Created
May 28, 2013 08:17
-
-
Save Partysun/5661268 to your computer and use it in GitHub Desktop.
Delete fail contacts from google contact service
Fail contact = doesn't have email or phone.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Delete fail contacts from google contact service | |
# Fail contact = doesn't have email or phone. | |
import gdata.contacts.service | |
import gdata.contacts | |
import getpass | |
client = gdata.contacts.service.ContactsService() | |
client.email = raw_input('Please enter your email address') | |
client.password = getpass.getpass() | |
client.source = 'Google-ContactsGetTest-1.0' | |
client.ProgrammaticLogin() | |
query = gdata.contacts.service.ContactsQuery() | |
query.max_results = 5000 | |
feed = client.GetContactsFeed(query.ToUri()) | |
i = 0 | |
for total, contact in enumerate(feed.entry): | |
if not(contact.email or contact.phone_number): | |
i += 1 | |
client.Delete(contact.GetEditLink().href) | |
print "Delete contact - %s" % contact.title.text | |
print "Complete." | |
print "You have %d contacts." % total | |
print "Delete %d fail contacts." % i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment