Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # a quick and dirty tool for extraction of contacts
- # and calendar entries from an owncloud sqlite3 database to text formats (ics, vcf)
- #
- # run it in your data directory where owncloud.db is stored
- import sqlite3
- c = sqlite3.connect('owncloud.db')
- f = open("calendar-export.ics", "w")
- pr = lambda x: f.write(x + "\n")
- # dummy vcalender template
- # HINT: modify if you are living somewhere else
- pr("""\
- BEGIN:VCALENDAR
- VERSION:2.0
- PRODID:-//SabreDAV//SabreDAV//EN
- CALSCALE:GREGORIAN
- X-WR-CALNAME:bla
- X-APPLE-CALENDAR-COLOR:#e78074
- BEGIN:VTIMEZONE
- TZID:Europe/Berlin
- X-LIC-LOCATION:Europe/Berlin
- BEGIN:DAYLIGHT
- TZOFFSETFROM:+0100
- TZOFFSETTO:+0200
- TZNAME:CEST
- DTSTART:19700329T020000
- RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
- END:DAYLIGHT
- BEGIN:STANDARD
- TZOFFSETFROM:+0200
- TZOFFSETTO:+0100
- TZNAME:CET
- DTSTART:19701025T030000
- RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
- END:STANDARD
- END:VTIMEZONE
- """)
- for row in c.execute("SELECT calendardata FROM oc_clndr_objects"):
- start_event = False
- for l in row[0].split("\n"):
- if "BEGIN:VEVENT" in l:
- start_event = True
- if start_event:
- pr(l)
- if "END:VEVENT" in l:
- start_event = False
- pr("END:VCALENDAR")
- print("calendar exported")
- f.close()
- f = open("contacts-export.vcf", "w")
- for row in c.execute("SELECT carddata FROM oc_contacts_cards"):
- pr(row[0])
- f.close()
- print("contacts exported")
- c.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement