Add Google Tasks to ICS converter

This commit is contained in:
Norbi Peti 2023-01-23 02:29:02 +01:00
parent 20232b17db
commit bcc652275e
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
3 changed files with 35 additions and 0 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
*.ics
Tasks.json
.idea

31
main.py Normal file
View file

@ -0,0 +1,31 @@
import json
from ics import Todo, Calendar, utils
f = open('Tasks.json')
lists = json.load(f)
for tasklist in lists["items"]:
cal = Calendar()
for task in tasklist["items"]:
todo = Todo()
todo.name = task["title"]
if "created" in task:
todo.created = utils.get_arrow(task["created"])
else:
todo.created = utils.get_arrow(task["updated"]) # Not ideal but what can you do
if "notes" in task:
todo.description = task["notes"]
if "due" in task:
todo.due = task["due"]
if task["status"] == "needsAction":
todo.status = "NEEDS-ACTION"
elif task["status"] == "completed":
todo.status = "COMPLETED"
todo.completed = utils.get_arrow(task["completed"])
todo.percent = 100
cal.todos.add(todo)
of = open(tasklist["title"] + ".ics", 'w')
of.write(cal.serialize())
of.close()
f.close()

1
requirements.txt Normal file
View file

@ -0,0 +1 @@
ics