commit f1a7e0dd4262b39efca46a79184e848ad7d1c92f Author: Ludwig Behm Date: Wed Oct 18 13:11:53 2023 +0200 init diff --git a/README.md b/README.md new file mode 100644 index 0000000..2eb70c8 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# jcal unfucker + +This oneliner converts streaming optimised jCal format from [rfc7265](https://datatracker.ietf.org/doc/rfc7265/) into a developer frendly json structure. + +## The actual code + +`jq '[(.[2][]|select(.[0] == "vevent")|.[1]|[.[]|{"key": .[0], "value": .[3]}]|from_entries)]'` + +## Example Usage + +```bash +curl -sH "Accept: application/calendar+json" https://cloud.kraut.space/remote.php/dav/public-calendars/2EkPGt3PF6WwYsA3\?export\&expand\=1\&start\=$(date -d '' +%s)\&end\=$(date -d 'next month' +%s) \ +| jq '[(.[2][]|select(.[0] == "vevent")|.[1]|[.[]|{"key": .[0], "value": .[3]}]|from_entries)]' +``` diff --git a/example.jcal b/example.jcal new file mode 100644 index 0000000..1bdfd08 --- /dev/null +++ b/example.jcal @@ -0,0 +1 @@ +["vcalendar",[["prodid",{},"text","-\/\/Sabre\/\/Sabre VObject 4.4.2\/\/EN"],["calscale",{},"text","GREGORIAN"],["version",{},"text","2.0"],["x-wr-calname",{},"unknown","Events im KrautSpace (lbehm)"],["x-apple-calendar-color",{},"unknown","#9750A4"],["refresh-interval",{},"duration","PT4H"],["x-published-ttl",{},"unknown","PT4H"]],[["vevent",[["created",{},"date-time","2023-10-17T21:13:30Z"],["dtstamp",{},"date-time","2023-10-17T21:15:47Z"],["last-modified",{},"date-time","2023-10-17T21:15:47Z"],["sequence",{},"integer",3],["uid",{},"text","0449bf5c-41c1-4868-9597-618a74f68377"],["dtstart",{},"date-time","2023-11-04T13:00:00Z"],["dtend",{},"date-time","2023-11-04T18:00:00Z"],["status",{},"text","CONFIRMED"],["summary",{},"text","Mitgliederversammlung"],["location",{},"text","Hackspace Jena e.V."],["color",{},"unknown","khaki"],["description",{},"text","F\u00fcr weitere Informationen siehe: https:\/\/senf.kraut.space\/t\/einladung-zur-mitgliederversammlung-2023\/205"]],[]],["vevent",[["created",{},"date-time","2022-06-02T17:56:49Z"],["dtstamp",{},"date-time","2022-06-02T18:02:07Z"],["last-modified",{},"date-time","2022-06-02T18:02:07Z"],["sequence",{},"integer",2],["uid",{},"text","c3178360-55bc-44e1-b8c1-3abc11d3f14f"],["dtstart",{},"date-time","2023-11-02T19:00:49Z"],["dtend",{},"date-time","2023-11-02T20:00:49Z"],["status",{},"text","CONFIRMED"],["color",{},"unknown","steelblue"],["location",{},"text","https:\/\/talk.kabi.tk\/krautspace"],["summary",{},"text","Plenum"],["description",{},"text","Offene Vereins-Plenumssitzung"],["recurrence-id",{},"date-time","2023-11-02T19:00:49Z"]],[]],["vevent",[["created",{},"date-time","2022-06-02T19:03:57Z"],["dtstamp",{},"date-time","2022-06-02T19:36:50Z"],["last-modified",{},"date-time","2023-09-20T18:00:00Z"],["sequence",{},"integer",2],["uid",{},"text","b6c74c49-db06-4f5f-a728-e4e77db36a45"],["dtstart",{},"date-time","2023-10-19T18:00:00Z"],["dtend",{},"date-time","2023-10-19T19:00:00Z"],["status",{},"text","CONFIRMED"],["summary",{},"text","Vorstandssitzung"],["color",{},"unknown","steelblue"],["attendee",{"cn":"Thomas Lotze","cutype":"INDIVIDUAL","partstat":"NEEDS-ACTION","role":"REQ-PARTICIPANT","rsvp":"TRUE","language":"en","schedule-status":"1.2"},"cal-address","mailto:thomas@thomas-lotze.de"],["attendee",{"cn":"Jens Kubieziel","cutype":"INDIVIDUAL","partstat":"ACCEPTED","role":"REQ-PARTICIPANT","language":"de","schedule-status":"2.0"},"cal-address","mailto:jens@kubieziel.de"],["attendee",{"cn":"jgo","cutype":"INDIVIDUAL","partstat":"NEEDS-ACTION","role":"REQ-PARTICIPANT","rsvp":"TRUE","language":"de","schedule-status":"1.2"},"cal-address","mailto:juergengoericke@mail.de"],["organizer",{"cn":"Ludwig Behm"},"cal-address","mailto:ludwig@behm.me"],["recurrence-id",{},"date-time","2023-10-19T18:00:00Z"]],[["valarm",[["x-evolution-alarm-uid",{},"unknown","c03fd8300eb9aa0c6d43e2d6861028bf49b9208f"],["action",{},"text","EMAIL"],["trigger",{"related":"START"},"duration","-P1D"],["acknowledged",{},"date-time","2023-09-20T18:00:00Z"]],[]]]],["vevent",[["created",{},"date-time","2022-06-02T19:03:57Z"],["dtstamp",{},"date-time","2022-06-02T19:36:50Z"],["last-modified",{},"date-time","2023-09-20T18:00:00Z"],["sequence",{},"integer",2],["uid",{},"text","b6c74c49-db06-4f5f-a728-e4e77db36a45"],["dtstart",{},"date-time","2023-11-16T19:00:00Z"],["dtend",{},"date-time","2023-11-16T20:00:00Z"],["status",{},"text","CONFIRMED"],["summary",{},"text","Vorstandssitzung"],["color",{},"unknown","steelblue"],["attendee",{"cn":"Thomas Lotze","cutype":"INDIVIDUAL","partstat":"NEEDS-ACTION","role":"REQ-PARTICIPANT","rsvp":"TRUE","language":"en","schedule-status":"1.2"},"cal-address","mailto:thomas@thomas-lotze.de"],["attendee",{"cn":"Jens Kubieziel","cutype":"INDIVIDUAL","partstat":"ACCEPTED","role":"REQ-PARTICIPANT","language":"de","schedule-status":"2.0"},"cal-address","mailto:jens@kubieziel.de"],["attendee",{"cn":"jgo","cutype":"INDIVIDUAL","partstat":"NEEDS-ACTION","role":"REQ-PARTICIPANT","rsvp":"TRUE","language":"de","schedule-status":"1.2"},"cal-address","mailto:juergengoericke@mail.de"],["organizer",{"cn":"Ludwig Behm"},"cal-address","mailto:ludwig@behm.me"],["recurrence-id",{},"date-time","2023-11-16T19:00:00Z"]],[["valarm",[["x-evolution-alarm-uid",{},"unknown","c03fd8300eb9aa0c6d43e2d6861028bf49b9208f"],["action",{},"text","EMAIL"],["trigger",{"related":"START"},"duration","-P1D"],["acknowledged",{},"date-time","2023-09-20T18:00:00Z"]],[]]]],["vevent",[["created",{},"date-time","2022-11-20T16:57:48Z"],["dtstamp",{},"date-time","2022-11-20T16:57:48Z"],["last-modified",{},"date-time","2022-11-20T16:57:48Z"],["sequence",{},"integer",0],["uid",{},"text","9bb5d3db-fcff-48d9-8ce9-f1565d6aa444"],["dtstart",{},"date-time","2023-10-19T20:00:00Z"],["dtend",{},"date-time","2023-10-19T21:00:00Z"],["status",{},"text","CONFIRMED"],["summary",{},"text","Linux User Group"],["location",{},"text","Krautgasse 26 und online unter https:\/\/talk.kabi.tk\/krautspace"],["description",{},"text","Diskussionen rund um das Freie Betriebssystem Linux"],["related-to",{"reltype":"SIBLING"},"text","1accce61-f8de-4b8b-b61c-814172cb9e5e"],["recurrence-id",{},"date-time","2023-10-19T20:00:00Z"]],[]],["vevent",[["created",{},"date-time","2022-11-20T16:57:48Z"],["dtstamp",{},"date-time","2022-11-20T16:57:48Z"],["last-modified",{},"date-time","2022-11-20T16:57:48Z"],["sequence",{},"integer",0],["uid",{},"text","9bb5d3db-fcff-48d9-8ce9-f1565d6aa444"],["dtstart",{},"date-time","2023-10-26T20:00:00Z"],["dtend",{},"date-time","2023-10-26T21:00:00Z"],["status",{},"text","CONFIRMED"],["summary",{},"text","Linux User Group"],["location",{},"text","Krautgasse 26 und online unter https:\/\/talk.kabi.tk\/krautspace"],["description",{},"text","Diskussionen rund um das Freie Betriebssystem Linux"],["related-to",{"reltype":"SIBLING"},"text","1accce61-f8de-4b8b-b61c-814172cb9e5e"],["recurrence-id",{},"date-time","2023-10-26T20:00:00Z"]],[]],["vevent",[["created",{},"date-time","2022-11-20T16:57:48Z"],["dtstamp",{},"date-time","2022-11-20T16:57:48Z"],["last-modified",{},"date-time","2022-11-20T16:57:48Z"],["sequence",{},"integer",0],["uid",{},"text","9bb5d3db-fcff-48d9-8ce9-f1565d6aa444"],["dtstart",{},"date-time","2023-11-02T20:00:00Z"],["dtend",{},"date-time","2023-11-02T21:00:00Z"],["status",{},"text","CONFIRMED"],["summary",{},"text","Linux User Group"],["location",{},"text","Krautgasse 26 und online unter https:\/\/talk.kabi.tk\/krautspace"],["description",{},"text","Diskussionen rund um das Freie Betriebssystem Linux"],["related-to",{"reltype":"SIBLING"},"text","1accce61-f8de-4b8b-b61c-814172cb9e5e"],["recurrence-id",{},"date-time","2023-11-02T20:00:00Z"]],[]],["vevent",[["created",{},"date-time","2022-11-20T16:57:48Z"],["dtstamp",{},"date-time","2022-11-20T16:57:48Z"],["last-modified",{},"date-time","2022-11-20T16:57:48Z"],["sequence",{},"integer",0],["uid",{},"text","9bb5d3db-fcff-48d9-8ce9-f1565d6aa444"],["dtstart",{},"date-time","2023-11-09T20:00:00Z"],["dtend",{},"date-time","2023-11-09T21:00:00Z"],["status",{},"text","CONFIRMED"],["summary",{},"text","Linux User Group"],["location",{},"text","Krautgasse 26 und online unter https:\/\/talk.kabi.tk\/krautspace"],["description",{},"text","Diskussionen rund um das Freie Betriebssystem Linux"],["related-to",{"reltype":"SIBLING"},"text","1accce61-f8de-4b8b-b61c-814172cb9e5e"],["recurrence-id",{},"date-time","2023-11-09T20:00:00Z"]],[]],["vevent",[["created",{},"date-time","2022-11-20T16:57:48Z"],["dtstamp",{},"date-time","2022-11-20T16:57:48Z"],["last-modified",{},"date-time","2022-11-20T16:57:48Z"],["sequence",{},"integer",0],["uid",{},"text","9bb5d3db-fcff-48d9-8ce9-f1565d6aa444"],["dtstart",{},"date-time","2023-11-16T20:00:00Z"],["dtend",{},"date-time","2023-11-16T21:00:00Z"],["status",{},"text","CONFIRMED"],["summary",{},"text","Linux User Group"],["location",{},"text","Krautgasse 26 und online unter https:\/\/talk.kabi.tk\/krautspace"],["description",{},"text","Diskussionen rund um das Freie Betriebssystem Linux"],["related-to",{"reltype":"SIBLING"},"text","1accce61-f8de-4b8b-b61c-814172cb9e5e"],["recurrence-id",{},"date-time","2023-11-16T20:00:00Z"]],[]],["vevent",[["created",{},"date-time","2022-11-20T16:59:01Z"],["dtstamp",{},"date-time","2022-11-20T16:59:01Z"],["last-modified",{},"date-time","2022-11-20T16:59:01Z"],["sequence",{},"integer",0],["uid",{},"text","39588c60-048d-4903-86da-1690ec6ca221"],["dtstart",{},"date-time","2023-10-27T17:00:00Z"],["dtend",{},"date-time","2023-10-27T21:00:00Z"],["status",{},"text","CONFIRMED"],["summary",{},"text","Gaming am Freitag"],["location",{},"text","Hackspace Jena e. V., Krautgasse 26, Jena"],["description",{},"text","Der Stammtisch f\u00fcr Videospielkultur!\nMehr Infor unter https:\/\/wiki.kraut.space\/hswiki:veranstaltungen:regelmaessige:gaming"],["related-to",{"reltype":"SIBLING"},"text","94f9690d-65ec-4e99-83df-83f7d3dbe202"],["recurrence-id",{},"date-time","2023-10-27T17:00:00Z"]],[]],["vevent",[["created",{},"date-time","2022-11-20T16:59:01Z"],["dtstamp",{},"date-time","2022-11-20T16:59:01Z"],["last-modified",{},"date-time","2022-11-20T16:59:01Z"],["sequence",{},"integer",0],["uid",{},"text","39588c60-048d-4903-86da-1690ec6ca221"],["dtstart",{},"date-time","2023-11-10T18:00:00Z"],["dtend",{},"date-time","2023-11-10T22:00:00Z"],["status",{},"text","CONFIRMED"],["summary",{},"text","Gaming am Freitag"],["location",{},"text","Hackspace Jena e. V., Krautgasse 26, Jena"],["description",{},"text","Der Stammtisch f\u00fcr Videospielkultur!\nMehr Infor unter https:\/\/wiki.kraut.space\/hswiki:veranstaltungen:regelmaessige:gaming"],["related-to",{"reltype":"SIBLING"},"text","94f9690d-65ec-4e99-83df-83f7d3dbe202"],["recurrence-id",{},"date-time","2023-11-10T18:00:00Z"]],[]],["vevent",[["created",{},"date-time","2022-11-20T17:02:09Z"],["dtstamp",{},"date-time","2023-09-29T19:34:34Z"],["last-modified",{},"date-time","2023-09-29T19:34:34Z"],["sequence",{},"integer",1],["uid",{},"text","bd4b600a-09f2-4966-9a8a-6a742b084f84"],["dtstart",{},"date-time","2023-10-18T18:00:00Z"],["dtend",{},"date-time","2023-10-18T21:00:00Z"],["status",{},"text","CONFIRMED"],["summary",{},"text","Brettspielrunde"],["description",{},"text","Mehr Infos unter https:\/\/kraut.space\/brettspielerei"],["related-to",{"reltype":"SIBLING"},"text","e7bfcc52-2747-4c46-bd4f-06b8c0062ccf"],["recurrence-id",{},"date-time","2023-10-18T18:00:00Z"]],[]],["vevent",[["created",{},"date-time","2022-11-20T17:02:09Z"],["dtstamp",{},"date-time","2023-09-29T19:34:34Z"],["last-modified",{},"date-time","2023-09-29T19:34:34Z"],["sequence",{},"integer",1],["uid",{},"text","bd4b600a-09f2-4966-9a8a-6a742b084f84"],["dtstart",{},"date-time","2023-11-01T19:00:00Z"],["dtend",{},"date-time","2023-11-01T22:00:00Z"],["status",{},"text","CONFIRMED"],["summary",{},"text","Brettspielrunde"],["description",{},"text","Mehr Infos unter https:\/\/kraut.space\/brettspielerei"],["related-to",{"reltype":"SIBLING"},"text","e7bfcc52-2747-4c46-bd4f-06b8c0062ccf"],["recurrence-id",{},"date-time","2023-11-01T19:00:00Z"]],[]],["vevent",[["created",{},"date-time","2022-11-20T17:02:09Z"],["dtstamp",{},"date-time","2023-09-29T19:34:34Z"],["last-modified",{},"date-time","2023-09-29T19:34:34Z"],["sequence",{},"integer",1],["uid",{},"text","bd4b600a-09f2-4966-9a8a-6a742b084f84"],["dtstart",{},"date-time","2023-11-15T19:00:00Z"],["dtend",{},"date-time","2023-11-15T22:00:00Z"],["status",{},"text","CONFIRMED"],["summary",{},"text","Brettspielrunde"],["description",{},"text","Mehr Infos unter https:\/\/kraut.space\/brettspielerei"],["related-to",{"reltype":"SIBLING"},"text","e7bfcc52-2747-4c46-bd4f-06b8c0062ccf"],["recurrence-id",{},"date-time","2023-11-15T19:00:00Z"]],[]],["vevent",[["created",{},"date-time","2022-11-20T16:49:34Z"],["dtstamp",{},"date-time","2022-11-20T16:49:34Z"],["last-modified",{},"date-time","2022-11-20T16:49:34Z"],["sequence",{},"integer",0],["uid",{},"text","01c81c49-d246-4efb-963d-c9e69565dbce"],["dtstart",{},"date-time","2023-10-24T18:00:00Z"],["dtend",{},"date-time","2023-10-24T21:00:00Z"],["status",{},"text","CONFIRMED"],["summary",{},"text","Chaostreff"],["description",{},"text","Offene Runde ... Mehr Informationen unter https:\/\/wiki.kraut.space\/hswiki:veranstaltungen:regelmaessige:chaostreff:start"],["location",{},"text","Krautgasse 26 und online unter https:\/\/kraut.space\/chaostreff"],["related-to",{"reltype":"SIBLING"},"text","2a5dc10d-30c0-49c4-82c4-ade2b6ffbdaf"],["recurrence-id",{},"date-time","2023-10-24T18:00:00Z"]],[]],["vevent",[["created",{},"date-time","2022-11-20T16:49:34Z"],["dtstamp",{},"date-time","2022-11-20T16:49:34Z"],["last-modified",{},"date-time","2022-11-20T16:49:34Z"],["sequence",{},"integer",0],["uid",{},"text","01c81c49-d246-4efb-963d-c9e69565dbce"],["dtstart",{},"date-time","2023-10-31T19:00:00Z"],["dtend",{},"date-time","2023-10-31T22:00:00Z"],["status",{},"text","CONFIRMED"],["summary",{},"text","Chaostreff"],["description",{},"text","Offene Runde ... Mehr Informationen unter https:\/\/wiki.kraut.space\/hswiki:veranstaltungen:regelmaessige:chaostreff:start"],["location",{},"text","Krautgasse 26 und online unter https:\/\/kraut.space\/chaostreff"],["related-to",{"reltype":"SIBLING"},"text","2a5dc10d-30c0-49c4-82c4-ade2b6ffbdaf"],["recurrence-id",{},"date-time","2023-10-31T19:00:00Z"]],[]],["vevent",[["created",{},"date-time","2022-11-20T16:49:34Z"],["dtstamp",{},"date-time","2022-11-20T16:49:34Z"],["last-modified",{},"date-time","2022-11-20T16:49:34Z"],["sequence",{},"integer",0],["uid",{},"text","01c81c49-d246-4efb-963d-c9e69565dbce"],["dtstart",{},"date-time","2023-11-07T19:00:00Z"],["dtend",{},"date-time","2023-11-07T22:00:00Z"],["status",{},"text","CONFIRMED"],["summary",{},"text","Chaostreff"],["description",{},"text","Offene Runde ... Mehr Informationen unter https:\/\/wiki.kraut.space\/hswiki:veranstaltungen:regelmaessige:chaostreff:start"],["location",{},"text","Krautgasse 26 und online unter https:\/\/kraut.space\/chaostreff"],["related-to",{"reltype":"SIBLING"},"text","2a5dc10d-30c0-49c4-82c4-ade2b6ffbdaf"],["recurrence-id",{},"date-time","2023-11-07T19:00:00Z"]],[]],["vevent",[["created",{},"date-time","2022-11-20T16:49:34Z"],["dtstamp",{},"date-time","2022-11-20T16:49:34Z"],["last-modified",{},"date-time","2022-11-20T16:49:34Z"],["sequence",{},"integer",0],["uid",{},"text","01c81c49-d246-4efb-963d-c9e69565dbce"],["dtstart",{},"date-time","2023-11-14T19:00:00Z"],["dtend",{},"date-time","2023-11-14T22:00:00Z"],["status",{},"text","CONFIRMED"],["summary",{},"text","Chaostreff"],["description",{},"text","Offene Runde ... Mehr Informationen unter https:\/\/wiki.kraut.space\/hswiki:veranstaltungen:regelmaessige:chaostreff:start"],["location",{},"text","Krautgasse 26 und online unter https:\/\/kraut.space\/chaostreff"],["related-to",{"reltype":"SIBLING"},"text","2a5dc10d-30c0-49c4-82c4-ade2b6ffbdaf"],["recurrence-id",{},"date-time","2023-11-14T19:00:00Z"]],[]],["vevent",[["created",{},"date-time","2022-11-20T17:01:02Z"],["last-modified",{},"date-time","2023-05-08T18:24:04Z"],["dtstamp",{},"date-time","2023-05-08T18:24:04Z"],["uid",{},"text","c4d419ac-6cf1-4bb9-862b-0033507285c2"],["summary",{},"text","Kinderbasteln"],["related-to",{"reltype":"SIBLING"},"text","82fee689-f801-4747-ae5d-6c386aaddc81"],["dtstart",{},"date-time","2023-10-28T08:00:00Z"],["dtend",{},"date-time","2023-10-28T10:00:00Z"],["transp",{},"text","OPAQUE"],["sequence",{},"integer",3],["x-moz-generation",{},"unknown","5"],["description",{},"text","Natur und Technik f\u00fcr Vor- und Grundschulkinder. Mehr informationen unter https:\/\/kraut.space\/kinderbasteln."],["location",{},"text","Krautgasse 26"],["recurrence-id",{},"date-time","2023-10-28T08:00:00Z"]],[]],["vevent",[["created",{},"date-time","2022-06-03T11:25:55Z"],["last-modified",{},"date-time","2023-10-10T19:56:00Z"],["dtstamp",{},"date-time","2023-10-10T19:56:00Z"],["uid",{},"text","905f0771-3df9-4bd9-99fb-68cf77365a75"],["summary",{},"text","Kinderbasteln"],["status",{},"text","CONFIRMED"],["dtstart",{},"date-time","2023-11-11T09:00:00Z"],["dtend",{},"date-time","2023-11-11T11:00:00Z"],["sequence",{},"integer",11],["location",{},"text","Krautspace"],["x-moz-generation",{},"unknown","9"],["recurrence-id",{},"date-time","2023-11-11T09:00:00Z"]],[]]]] \ No newline at end of file diff --git a/jcal-unfuck.jq b/jcal-unfuck.jq new file mode 100755 index 0000000..401435c --- /dev/null +++ b/jcal-unfuck.jq @@ -0,0 +1,10 @@ +#!/usr/bin/jq -rfc +[ + ( + .[2][] # skipping calender header and accessing events + | [["_type", {}, "text", .[0]], .[1][]] # adding ical type like 'vevent' as ._type property + | [.[] | {"key": .[0], "value": .[3]}] | from_entries # transforming event array structure into object structure + | pick(._type, .dtstart, .dtend, .summary, .location, .description, .sequence, .["related-to"]) # allow list of properties + ) +] +| sort_by(.dtstart|fromdate) # sorting by event start time