Beginner 3rd-party hacking: importing birthdays via CardDAV or OCS

I have a Nextcloud 21 server and I’d like to add birthday data to ~200 of my contacts that are already in the Contacts app. I have matching first names, last names in a GEDCOM plain text data file (family tree data), along with the birthdays I want to migrate over. I’m planning on munging first name, last name, and birthday from GEDCOM into a data structure in Python or JavaScript and using the OCS or CardDAV interface to do this for each birthday:

  1. find a matching contact in Nextcloud Contacts app
  2. update that contact, adding their birthday

Any tips on how to get started? So far I’ve found:

This is basically a one-off, I don’t care about reusability. I figure once I get the data into Nextcloud, the next migration will be easier.

I haven’t investigated JavaScript libraries much… maybe I could just paste in a data structure and some code into my browser console while I am logged in?

An other way would be to use cadaver to mount the CardDAV address book on your local maschine and then edit the available vcf files, one by one using a shell script.

2 Likes

Thank you! I made some progress with your idea but I’m stumped once again.

I was able to dump names and birthdays to CSV using python-gedcom and converted birth dates to VCF format using datetime.datetime.strptime(bday, '%d %b %Y').strftime('%Y%m%d'). My file manager mounts Nextcloud no problem, and it then shows up on my filesystem under /run/user/$UID/dav:host=example.com,ssl=true,prefix=%2Fremote.php%2Fdav/addressbooks/users/username, and each folder under there is one of my address books with a bunch of .vcf files that I can manipulate directly! Nice!

Unfortunately (say, when I cat a .vcf file) sometimes the vCards end with END: instead of the proper END:VCARD, and sometimes they appear to be truncated even sooner (say, halfway through photo data). I also notice they are v3 vCards, which is different than the v4 vCards fetched from a PROPFIND of a Nextcloud Contacts .vcf URL in a web browser. I can view the proper-looking v4 vCard in my browser’s developer console.

Data is stored in Nextcloud as it has been created by a CardDAV client. Therefore it might be possible that the data is stored in different formats (v3 vs v4) and that it contains syntax errors.
If you can reproduce the different vcf-file problems, like shortened data etc., you should open an issue ticket in the related Nextcloud server repository to get that problem solved.

I think they are aware of the issues:

Possibly also related: