Coder Social home page Coder Social logo

ics2owncloud.py's Introduction

ics2owncloud.py

This script downloads iCal files and imports them to ownCloud using CalDAV.

Pull requests welcome!

Important note

The calendar app supports calendar subscriptions for some time now. However these calendars can't be sync'd to your devices. If you need this you can still use this script to import events to "normal" calendars that are available for sync'ing.

Requirements

Just make sure the virtualenv command is in $PATH when running ics2owncloud.sh. icalendar and Requests are installed automatically.

Installation

$ git clone https://github.com/buzz/ics2owncloud.py.git

Configuration

Configuration file

Create and edit config file:

cp ics2owncloud.ini.example ~/.ics2owncloud.ini

A config file with two entries looks like this:

[DEFAULT]
username: tom
password: 123456
server: https://cloud.example.com/

[import_a]
calendar: calendar_xy
ics_url: https://USER1:[email protected]/index.php/apps/calendar/export.php?calid=6

[import_b]
calendar: facebook
ics_url: https://www.facebook.com/ical/u.php?uid=10000123456789&key=ABCDEFGHIJKL
  • username - ownCloud user
  • password - ownCloud password
  • server - ownCloud server URL
  • calender - ownCloud calendar name
  • ics_url - URL to the ICS file to download (can have username:password format)

Don't forget to protect your config file:

$ chmod 600 ~/.ics2owncloud.ini

Cron job

A cron job comes in handy to periodically import calendars:

$ crontab -e

This runs the script every 30 minutes:

*/30 * * * * /PATH/TO/ics2owncloud.sh >/dev/null

ics2owncloud.py's People

Contributors

buzz avatar canoine avatar lasse-it avatar ledfan avatar maxqia avatar mossroy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ics2owncloud.py's Issues

Script fails when UID is an URL

I have exported my outlook calendar. One of the events is defined in ics as follows (see UID, bolded part):
BEGIN:VEVENT
UID:https://www.domain.com/webcast/11111/22222
SUMMARY:Zajęty
DTSTART;TZID=Central Europe Standard Time:20160712T140000
DTEND;TZID=Central Europe Standard Time:20160712T150000
CLASS:PUBLIC
PRIORITY:5
DTSTAMP:20160713T171942Z
TRANSP:OPAQUE
STATUS:CONFIRMED
SEQUENCE:1467877786
X-MICROSOFT-CDO-APPT-SEQUENCE:1467877786
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
X-MICROSOFT-CDO-IMPORTANCE:1
X-MICROSOFT-CDO-INSTTYPE:0
X-MICROSOFT-DISALLOW-COUNTER:FALSE
END:VEVENT
and triggers an error:
HTTPError: 404 Client Error: Not Found for url: https://cloud.mydomain.pl/remote.php/caldav/calendars/user/calendar/https://www.domain.com/webcast/11111/22222.ics

Calendar item in question was an invitation to the webinar, in outlook it looks like all others.
If I store the calendar into ics file and import it via OC GUI it works fine.

Deleted events don't stay in OC / Don't wipe calendar beforehand?

Hi, and thanks a lot for this wonderful utility - even if it's just meant as a workaround until the functionality becomes a first-class member in OC. By the way, IIUC it could be ics2caldav - there's nothing OC-specific, right?

My suggestion is actually a counter-request to #1 and #7, and would make this ics2owncloud independently useful even if remote calendars will be integrated in OC at some point. I subscribe to some calendars where I do want to keep the history locally, despite the fact that the feed only shows future events. E.g., I want to be shown the holidays from former years although my feed only shows the current and future years; or I want to keep a list of former talks and meetings in our institute; or I want to keep "verbatim" copies of shared calendars where other parties might delete or change history.

Do you think it's feasible to make the wipe optional?

Additional kudos if only future events could be wiped separately and replaced by the current remote content, with the following rationale: if announcements change or are cancelled entirely (rarely the case for holidays, entirely possible for talks), the future should be updated accordingly; but past events could be kept.

Cheers!

Deleted events stay in OC

Hi,

First, thanks for your tools because I can't use OC Calendar without remote calendars subscriptions.

However, the events which are deleted on the remote calendar stay presents into OC calendars.

Did you think that you can fix it before the version 1.1 (planned for the 12/04 (DD/MM)) update of OC calendar app ? Perhaps it will be nice to delete all events before import then into OC.

Regards
R_K

Wipe calendar beforehand?

Does this script also wipe the calendar before it imports the new events?
This was a feature from Georg's script and would be needed by me.

SyntaxError: (unicode error) 'unicodeescape'

Thanks for your script. I'm running this to sync a ms outlook calendar with owncloud 9 and I'm getting this error:
File "ics2owncloud.py", line 46 if r.status_code == 500 and 'Sabre\VObject\Recur\NoInstancesException' in r.text: ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 19-20: malformed \N character escape

Any ideas?

THIS SCRIPT IS DEPRECATED.

I disagree with the "THIS SCRIPT IS DEPRECATED." mention in the project's README.md, you can indeed now subscribe to an external ICS URL via the OwnCloud calendar and import it regularly, but one feature that is lacking is that this "imported calendar" is not available via CalDAV for syncing with other devices (Smartphone for example).

And this is precisely where your script comes in handy, since the ICS is imported into an existing calendar that can then be synced to other devices, which is exactly what I need :)

Selfsigned Certificate

Thanks for your script!
I ran into problems, as my certificate is self-signed.
As I don't know how python stores certificates I simply inserted
the option verify=False for all requests. Perhaps you could integrate a config-option?
Best regards,
Thomas

Client Error: Not found for URL...

Greetings,

I am glad to see that my php code was useful ;-)
(I posted it on the forum you referred to)

As my script is not good with new calendar app, I wanted to use your script. But I cannot get it running.

I get:
HTTPError: 404 Client Error: Not Found for url: https://cloud.domain.pl/remote.php/caldav/calendars/user/calendar_name?export

When I changed the password to the wrong one in ini file the error message changed to:
HTTPError: 401 Client Error: Unauthorized for url: https:....
so there is a connection to the server.
I checked both with /dav/ and /caldav/ in url, same result.
I am on OC 9.0.2 with Calendar app 1.2.2. OC server in behind the Apache proxy, but it should be transparent.

Any hints?

ValueError: Found no components where exactly one is required: u''

Hi, for two days I get the following error messages:

Traceback (most recent call last): File "./ics2owncloud.py", line 77, in <module> Config.get(key, 'ics_url'), File "./ics2owncloud.py", line 33, in do_import c = Calendar.from_ical(requests.get(ics_url).text) File "/usr/lib64/python2.7/site-packages/icalendar/cal.py", line 367, in from_ical '{st!r}'.format(**locals())) ValueError: Found no components where exactly one is required: u''

What's going wrong?

Items added with the script are not exported via caldav

Hi, i dont know if the problem is with the script, or the dav functionality, but items added by the script, which appear in the calendar gui, are not shared via the caldav endpoint, when items manually added to the same calendar are.

SSL Error

Thanks for this Script, but i got this error:

SSLError: [Errno 1] _ssl.c:510: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

its an trusted letsencrypt certificate
look here: https://cloud-surfer.eu

caldav

Hi!
In order for your script to work for me I hat to change the URL to owncloud

Before:
CALDAVURL = '%sremote.php/dav/calendars/%s/%s'

After:
CALDAVURL = '%sremote.php/caldav/calendars/%s/%s'

Thanks for your script! I used the same php script as you :-D

404 no calendar found

If run the script i get the error:
HTTPError: 404 Client Error: Not Found for url: https://<cloud>:<port>/owncloud/remote.php/dav/calendars/<user>/<calendar>?export Traceback (most recent call last): File "./ics2owncloud.py", line 78, in <module> Config.get(key, 'ics_url'), File "./ics2owncloud.py", line 22, in do_import r.raise_for_status() File "/opt/ics2owncloud/venv/local/lib/python2.7/site-packages/requests/models.py", line 840, in raise_for_status raise HTTPError(http_error_msg, response=self)

What went wrong?

Pyhton3 support

This script should probably be converted to support Python3?

Anyone?

Busy status converted to English

I exported my outlook calendar (just free/busy status) into ics file. In exported ics file status is in Polish (zajęty for busy). When I import it with your script, the calendar item is stored as busy (translated into English). The same ics file imported via gui gives calendar items in my local language.

Work with oc 10?

Hello,

i tried the script with oc 10, but it does not work. No imported items, no errors!?

Regards
Maik

Seem to not do anything

Hello,

I use your software together with ownCloud 9.1 and Calendar 1.3.1 . But somehow when I run your script nothing happens, not even an error is shown up. How can I tell what happens, can you please make your script a bit more verbose?

rgds schabi

Optionally ignore certificate errors

The certificate of a server can be either expired (the letsencrypt scripts did not run for a time 😈 ) or can be issued via an company internal certificate authority.

In any case, it might be helpful to have a way to ignore certificate validation errors.

Also mentioned in #5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.