-
Notifications
You must be signed in to change notification settings - Fork 4
/
gvmessages.py
77 lines (72 loc) · 1.82 KB
/
gvmessages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python
from sys import exit, argv
from googlevoice import Voice
import json
voice = Voice()
try:
email = argv[1]
except:
print ('Error! Please provide Email Account. ')
exit(0)
try:
password = argv[2]
except:
print ('Error! Please provide Passsword. ')
exit(0)
try:
voice.login(email,password)
except:
print ('Error! Login failed. ')
exit(0)
try:
command = argv[3]
except:
print ('Error! Please provide a phone number or FOLDER. ')
voice.logout()
exit(0)
if command == "Inbox" :
folder = voice.inbox().messages
foundmsg = [ msg for msg in folder]
elif command == "Messages" :
folder = voice.sms().messages
foundmsg = [ msg for msg in folder]
elif command == "All" :
voice.all()
folder = voice.all.folder
foundmsg = [ msg for msg in folder.messages]
elif command == "Spam" :
voice.spam()
folder = voice.spam.folder
foundmsg = [ msg for msg in folder.messages]
elif command == "Trash" :
voice.trash()
folder = voice.trash.folder
foundmsg = [ msg for msg in folder.messages]
elif command == "Placed" :
folder = voice.placed().messages
foundmsg = [ msg for msg in folder]
elif command == "Received" :
voice.received()
folder = voice.received.messages
foundmsg = [ msg for msg in folder]
elif command == "Missed" :
folder = voice.missed().messages
foundmsg = [ msg for msg in folder]
#elif command == "History" :
#try:
#phone = argv[4]
#folder = voice.search(phone)
#foundmsg = [ msg for msg in folder.messages if (msg.messageText != "") ]
#except:
#print ('Error! Please provide a phone number. ')
#voice.logout()
#exit(0)
else:
folder = voice.search(command)
foundmsg = [ msg for msg in folder.messages]
if foundmsg != []:
foundmsg.sort(key=lambda x:x['displayStartDateTime'], reverse=True)
print json.dumps(foundmsg, indent=4, default=str)
else:
print('Nothing found! ')
voice.logout()