|
@@ -1,3 +1,4 @@
|
|
|
|
|
+#!/usr/bin/python3
|
|
|
# coding=utf-8
|
|
# coding=utf-8
|
|
|
# Doc
|
|
# Doc
|
|
|
# Script to extract Contacts from Sailfish Contact SQLite DB located at
|
|
# Script to extract Contacts from Sailfish Contact SQLite DB located at
|
|
@@ -7,8 +8,12 @@
|
|
|
# FileFormatdescription: https://docs.fileformat.com/email/vcf/#vcf-30-example
|
|
# FileFormatdescription: https://docs.fileformat.com/email/vcf/#vcf-30-example
|
|
|
# Pytho vobject: http://eventable.github.io/vobject/
|
|
# Pytho vobject: http://eventable.github.io/vobject/
|
|
|
|
|
|
|
|
|
|
+# Version
|
|
|
|
|
+version=0.2
|
|
|
|
|
+
|
|
|
# ChangeLog
|
|
# ChangeLog
|
|
|
-# 2021-08-03 - multiple E-Mails with different types are working correctly
|
|
|
|
|
|
|
+# 2021-08-03 - 0.1 - multiple E-Mails with different types are working correctly
|
|
|
|
|
+# 2021-08-09 - 0.2 - Phonenumbers with parameters, Addresses with parameters, E-Mail-Addresses with marameters
|
|
|
|
|
|
|
|
import sqlite3
|
|
import sqlite3
|
|
|
import vobject
|
|
import vobject
|
|
@@ -21,9 +26,10 @@ def DEBUG(debug,msg):
|
|
|
|
|
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description='Restore SailfishOS 3 Contacts', epilog='This script was written to restore SailfishOS 3 contacts as VCF files. To see additional information, visit: https://wiki.siningsoft.de/doku.php?id=sailfishos:projects:sailfish_contacts_rescue' )
|
|
parser = argparse.ArgumentParser(description='Restore SailfishOS 3 Contacts', epilog='This script was written to restore SailfishOS 3 contacts as VCF files. To see additional information, visit: https://wiki.siningsoft.de/doku.php?id=sailfishos:projects:sailfish_contacts_rescue' )
|
|
|
-parser.add_argument('--db','-d', help="Sqlite3 Database file usually /home/{nemo,defaultuser)/.local/share/system/Contacts/qtcontacts-sqlite/contacts.db")
|
|
|
|
|
-parser.add_argument('--output','-o',help="Output directory for vcf files")
|
|
|
|
|
|
|
+parser.add_argument('--db','-d', required=True, help="Sqlite3 Database file usually /home/{nemo,defaultuser)/.local/share/system/Contacts/qtcontacts-sqlite/contacts.db")
|
|
|
|
|
+parser.add_argument('--output','-o',required=True, help="Output directory for vcf files")
|
|
|
parser.add_argument('--debug',action="store_true",help="debugging output to identify problems")
|
|
parser.add_argument('--debug',action="store_true",help="debugging output to identify problems")
|
|
|
|
|
+parser.add_argument('--version', action='version', version='%(prog)s ' + str(version))
|
|
|
args = parser.parse_args()
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
@@ -48,10 +54,37 @@ try:
|
|
|
|
|
|
|
|
DEBUG(args.debug,"Contact " + row[1])
|
|
DEBUG(args.debug,"Contact " + row[1])
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ # abfrage der Adressdaten
|
|
|
SQLADRCur = SQLconn.cursor()
|
|
SQLADRCur = SQLconn.cursor()
|
|
|
for ADRrow in SQLADRCur.execute('SELECT * FROM Addresses JOIN Details on Details.detailId = Addresses.detailId where Addresses.contactId = ' + str(contactID)):
|
|
for ADRrow in SQLADRCur.execute('SELECT * FROM Addresses JOIN Details on Details.detailId = Addresses.detailId where Addresses.contactId = ' + str(contactID)):
|
|
|
- adr = vcf.add('ADR').value = vobject.vcard.Address(street=ADRrow[2], city=ADRrow[5], region=ADRrow[4], code=ADRrow[6],country=ADRrow[7])
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if ADRrow[2] is not None:
|
|
|
|
|
+ ADRstr=str(ADRrow[2])
|
|
|
|
|
+ else:
|
|
|
|
|
+ ADRstr=""
|
|
|
|
|
+
|
|
|
|
|
+ if ADRrow[5] is not None:
|
|
|
|
|
+ ADRcit=str(ADRrow[5])
|
|
|
|
|
+ else:
|
|
|
|
|
+ ADRcit=""
|
|
|
|
|
+
|
|
|
|
|
+ if ADRrow[4] is not None:
|
|
|
|
|
+ ADRreg=str(ADRrow[4])
|
|
|
|
|
+ else:
|
|
|
|
|
+ ADRreg=""
|
|
|
|
|
+
|
|
|
|
|
+ if ADRrow[6] is not None:
|
|
|
|
|
+ ADRcod=str(ADRrow[6])
|
|
|
|
|
+ else:
|
|
|
|
|
+ ADRcod=""
|
|
|
|
|
+
|
|
|
|
|
+ if ADRrow[7] is not None:
|
|
|
|
|
+ ADRcou=str(ADRrow[7])
|
|
|
|
|
+ else:
|
|
|
|
|
+ ADRcou=""
|
|
|
|
|
+
|
|
|
|
|
+ DEBUG(args.debug,"Addressdata: street=" + ADRstr + " city=" + ADRcit + " region=" + ADRreg + " code=" + ADRcod + " country=" + ADRcou)
|
|
|
|
|
+ adr = vcf.add('ADR').value = vobject.vcard.Address(street=ADRstr, city=ADRcit, region=ADRreg, code=ADRcod,country=ADRcou)
|
|
|
|
|
|
|
|
## Abfragen Organisation
|
|
## Abfragen Organisation
|
|
|
SQLORGCur = SQLconn.cursor()
|
|
SQLORGCur = SQLconn.cursor()
|
|
@@ -108,7 +141,7 @@ try:
|
|
|
|
|
|
|
|
|
|
|
|
|
# debug ausgabe
|
|
# debug ausgabe
|
|
|
- print("...debug: " + str(Phonerow[2]) + " at " + str(Phonerow[10]) + " subtype=" + str(Phonerow[3]))
|
|
|
|
|
|
|
+ DEBUG(args.debug,str(Phonerow[2]) + " at " + str(Phonerow[10]) + " subtype=" + str(Phonerow[3]))
|
|
|
|
|
|
|
|
# None is a normal phone Number
|
|
# None is a normal phone Number
|
|
|
|
|
|
|
@@ -126,7 +159,7 @@ try:
|
|
|
elif Phonerow[3] is None:
|
|
elif Phonerow[3] is None:
|
|
|
phcat='voice'
|
|
phcat='voice'
|
|
|
|
|
|
|
|
- print("...debug: " + phcat)
|
|
|
|
|
|
|
+ DEBUG(args.debug,phcat)
|
|
|
|
|
|
|
|
phone = vcf.add(phcat).value = str(Phonerow[2])
|
|
phone = vcf.add(phcat).value = str(Phonerow[2])
|
|
|
|
|
|