lucc / khard

Console vcard client
https://khard.readthedocs.io/en/latest/
GNU General Public License v3.0
600 stars 65 forks source link

Using khard with a single addressbook with multiple vcards #252

Closed ligurio closed 4 years ago

ligurio commented 4 years ago

Hello,

I'm imported addressbook from contats.google.com. It is a single file with vcards inside. khard cannot parse files with a reason WARNING:root:Card from address book personal has no UID and will not be availbale. Address book: personal. How to use khard with vcards in a single file?

Example:

BEGIN:VADDRESSBOOK
BEGIN:VCARD
VERSION:3.0
FN:AAA EEE
UID:00a57d3d-6702-4093-b7e8-a1abf0bbfae5
END:VCARD
BEGIN:VCARD
VERSION:3.0
FN:ZZZ AAA
UID:00edd30e-dd24-4c05-bb7e-08e2e93b23bc
END:VCARD
END:VADDRESSBOOK

With debug option:

DEBUG:root:first args=Namespace(config='', debug=True, remainder=[], skip_unparsable=False)
DEBUG:root:remainder=[]
DEBUG:root:updated remainder=['list']
DEBUG:root:second args=Namespace(action='list', addressbook=[], config='', debug=False, display=None, group_by_addressbook=False, parsable=False, reverse=False, search_in_source_files=False, search_terms=[], skip_unparsable=False, sort=None, strict_search=False, uid='')
DEBUG:root:Created source query regex: None
DEBUG:root:Created target query regex: None
DEBUG:root:Created query regex: {'personal': None}
DEBUG:root:Loading Vdir personal with query None
WARNING:root:Card  from address book personal has no UID and will not be availbale.
WARNING:root:Card  from address book personal has no UID and will not be availbale.
DEBUG:root:Loded 0 contacts from address book personal.
DEBUG:root:args.search_terms=.*
DEBUG:root:address book personal, searching with .*
Found no contacts

Version: Khard version 0.13.0

scheibler commented 4 years ago

Khard doesn't support multiple vcards in a single file.

You could try the following:

  1. Synchronize your Google account with vdirsyncer: https://www.mankier.com/1/vdirsyncer#Full_Configuration_Manual-Google Maybe Vdirsyncer splits the contacts automatically (didn't try that myself).

  2. I've written a Python script to split CalDAV files for my local calendar: https://www.eric-scheibler.de/en/blog/2014/10/Sync-calendars-and-address-books-between-Linux-and-Android/#import-calendars You could try to adapt the script for CardDav.

ligurio commented 4 years ago

@scheibler Thanks! Using multiple vcards is not an option. I'm using Baikal as a CardDAV/CalDAV server and DAVx5 as connector to it on Android. Both applications shows each vcard as a separate address book. So I see about 600 address books on as server and in DAVx5.

d7415 commented 4 years ago

Using multiple vcards is not an option. I'm using Baikal as a CardDAV/CalDAV server and DAVx5 as connector to it on Android. Both applications shows each vcard as a separate address book. So I see about 600 address books on as server and in DAVx5.

I can't speak for Baikal, but DAVx5 isn't your problem here. I have an address book synchronised with DAVx5 via a radicale server and it works fine. It may be your vdirsyncer or Baikal settings.

ligurio commented 4 years ago

Found an option type with possible values "singlefile" and "filesystem" in vdirsyncer. With singlefile vdirsyncer uses one file per calendar/addressbook and with filesystem vdirsyncer uses multiple files per calendar/addressbook. Perhaps it possible resolves my issue.

lucc commented 4 years ago

If someone wants to write support for single file address books in khard they could write a new class in address_book.py. But a thorough inspection has to be made before that because other code (e.g. the CarddavObject class) depend on the filename of the vcards. It might involve some bigger refactoring.

lucc commented 4 years ago

I updated the documentation.