diff --git a/README.md b/README.md
index f656197..c069b69 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,10 @@
Extract, parse, and decompress data from an Android Gmail database.
This is a standalone script.
+
+Changelog 20190127 [changes by [Petro Dudi](https://github.com/pdudis)]:
+
+- Adapted for Python 3.x
+- Added bad_chars_sub() to replace subject fields containing "/" and "\\" with "-", and return a string of 50 chars max
+- Added unicode support when writing decompressed body field to file
+- Prints account names and number of processed emails to standard output
diff --git a/android-gm-extractor.py b/android-gm-extractor.py
index 876a40a..7f6d83a 100755
--- a/android-gm-extractor.py
+++ b/android-gm-extractor.py
@@ -6,6 +6,18 @@
outputs to standard output with HTML
formatting.
+========================================
+Updated by Petro Dudi on 20190127
+- Adapted for Python 3.x
+- Added bad_chars_sub() to replace
+ subject fields containing "/" and "\"
+ with "-", and return a string of 50
+ chars max
+- Added unicode support when writing
+ decompressed body field to file
+- Prints account names and number of
+ processed emails to standard output
+
========================================
Updated by CBRYCE on 20150107
@@ -23,6 +35,7 @@
'''
import sys
+import os
import time
import sqlite3
import zlib
@@ -54,6 +67,14 @@ def bad_chars(string):
string = string.replace(char, '')
return string
+def bad_chars_sub(string):
+ '''Removes / and \ from string.
+ Returns cleaned string.'''
+ for char in ['/', '\\']:
+ if char in string:
+ string = string.replace(char, '-')
+ return string[0:50]
+
def main(path, outputPath):
con = sqlite3.connect(path)
@@ -79,30 +100,32 @@ def main(path, outputPath):
em_subject = row[8]
em_body = row[9]
- outputFile = open(outputPath+"/"+str(em_id)+"__"+str(em_subject), 'w')
+ outputFile = open(outputPath+"/"+str(em_id)+"__"+bad_chars_sub(em_subject)+".html", 'w')
outputFile.write('
')
write_css(outputFile)
outputFile.write('' +
- 'Subject:' + em_subject.encode('utf-8') + '
' +
+ 'Subject:' + str(em_subject) + '
' +
'Body:
')
if em_body:
dem_body = zlib.decompress(em_body)
- outputFile.write(dem_body)
+ outputFile.write(dem_body.decode('utf-8'))
outputFile.write('
')
email_count += 1
- outputFile.write('')
- #print email_count
+ outputFile.write('