Compare commits
No commits in common. "c9deeb88ab59bb0345dc62f1fa87fdfd92fff1e2" and "95a5b7d35c199f303ab18de914c7742699e911d3" have entirely different histories.
c9deeb88ab
...
95a5b7d35c
2 changed files with 12 additions and 28 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,2 +0,0 @@
|
||||||
*.vcf
|
|
||||||
/photo
|
|
||||||
|
|
@ -1,33 +1,19 @@
|
||||||
import pickle
|
import pickle
|
||||||
from pythonvCard4.vcard import Contact
|
from pythonvCard4.vcard import Contact
|
||||||
import base64
|
|
||||||
import os
|
|
||||||
|
|
||||||
file = open("contacts.vcf", 'r').readlines()
|
input = open("contacts.vcf", 'r').readlines()
|
||||||
|
output = open("processed.vcf", 'w')
|
||||||
|
|
||||||
cards = []
|
for line in input:
|
||||||
|
|
||||||
current_card = ""
|
if "TEL" in line:
|
||||||
for line in file:
|
line = line.replace('-', '')
|
||||||
current_card += line
|
if ":06" in line: line = line.replace(":06", ":+336")
|
||||||
if "END:VCARD" in line:
|
if ":07" in line: line = line.replace(":07", ":+337")
|
||||||
contact = Contact.from_vcard(current_card)
|
if ":00" in line: line = line.replace(":00", ":+")
|
||||||
if "PHOTO" in contact.custom and len(contact.custom["PHOTO"]) > 1:
|
if ":09" in line: line = line.replace(":09", ":+339")
|
||||||
os.makedirs("photo/" + contact.fn, exist_ok=True)
|
if ":01" in line: line = line.replace(":01", ":+331")
|
||||||
for image in range(len(contact.custom["PHOTO"])):
|
|
||||||
with open("photo/" + contact.fn + "/" + str(image) + ".jpg", "wb") as f:
|
|
||||||
f.write(base64.decodebytes(str.encode(contact.custom["PHOTO"][image])))
|
|
||||||
|
|
||||||
cards.append(contact)
|
print(line)
|
||||||
current_card = ""
|
|
||||||
continue
|
|
||||||
|
|
||||||
|
output.write(line)
|
||||||
# contact = Contact.from_vcard(cards[156])
|
|
||||||
# print(contact.custom["PHOTO"])
|
|
||||||
|
|
||||||
# vcf_text = contact.to_vcard()
|
|
||||||
# print(vcf_text)
|
|
||||||
# open('test.vcf', 'w').write(vcf_text)
|
|
||||||
|
|
||||||
print(len(cards))
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue