return json
- def download(self, messageId, adir):
+ def recording_url(self, messageId):
+ url = self._downloadVoicemailURL+messageId
+ return url
+
+ def download(self, messageId, targetPath):
"""
Download a voicemail or recorded call MP3 matching the given ``msg``
which can either be a ``Message`` instance, or a SHA1 identifier.
- Saves files to ``adir`` (defaults to current directory).
Message hashes can be found in ``self.voicemail().messages`` for example.
@returns location of saved file.
@blocks
"""
- page = self._get_page(self._downloadVoicemailURL, {"id": messageId})
- fn = os.path.join(adir, '%s.mp3' % messageId)
- with open(fn, 'wb') as fo:
+ page = self._get_page(self.recording_url(messageId))
+ with open(targetPath, 'wb') as fo:
fo.write(page)
- return fn
def is_valid_syntax(self, number):
"""
]
return self._parse_recent(recentPages)
- def get_contacts(self):
- """
- @returns Iterable of (contact id, contact name)
- @blocks
- """
- page = self._get_page(self._JSON_CONTACTS_URL)
- return self._process_contacts(page)
-
def get_csv_contacts(self):
data = {
"groupToExport": "mine",
recentCallData["action"] = action
yield recentCallData
- def _process_contacts(self, page):
- accountData = parse_json(page)
- for contactId, contactDetails in accountData["contacts"].iteritems():
- # A zero contact id is the catch all for unknown contacts
- if contactId != "0":
- yield contactId, contactDetails
-
def _parse_history(self, historyHtml):
splitVoicemail = self._seperateVoicemailsRegex.split(historyHtml)
for messageId, messageHtml in itergroup(splitVoicemail[1:], 2):
)
+def grab_voicemails(username, password):
+ cookieFile = os.path.join(".", "raw_cookies.txt")
+ try:
+ os.remove(cookieFile)
+ except OSError:
+ pass
+
+ backend = GVoiceBackend(cookieFile)
+ backend.login(username, password)
+ voicemails = list(backend.get_voicemails())
+ for voicemail in voicemails:
+ print voicemail.id
+ backend.download(voicemail.id, ".")
+
+
def main():
import sys
logging.basicConfig(level=logging.DEBUG)
password = args[2]
grab_debug_info(username, password)
+ grab_voicemails(username, password)
if __name__ == "__main__":