init
This commit is contained in:
commit
f1a7e0dd42
3 changed files with 25 additions and 0 deletions
14
README.md
Normal file
14
README.md
Normal file
|
@ -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)]'
|
||||
```
|
1
example.jcal
Normal file
1
example.jcal
Normal file
File diff suppressed because one or more lines are too long
10
jcal-unfuck.jq
Executable file
10
jcal-unfuck.jq
Executable file
|
@ -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
|
Loading…
Reference in a new issue