Skip to content

drinking-code/cn-to-cal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CampusNet to Calendar

This package synchronises your CampusNet dates to your Apple Calendar for the current and the next month. This package mainly exists because the CampusNet App has a bug where users get logged out regularly and date changes won't update. As this bug probably will not be fixed any time soon, this package will act as an interim solution.

Note: If you got here by browsing this package is probably not for you. Unless you also want to synchronise dates from a CampusNet to your Apple Calendar, in which case you want to change the URL in lib/cn-scraper.js

How it works

When you run the script on your computer, it will check (in the background) twice every day if there were any changes to your CampusNet dates and adjusts them in your cloud calendar. Your calendar app will then fetch the changes and show the correct dates on your phone. Here, I made a figure:

Figure 1

Installation

Where to install

This system will only work if the package runs on a computer that is turned on and online all the time or almost all the time. So, you got a few options:

  • run on your laptop / computer (good, when it's used daily in copious amounts)
  • run on a Raspberry Pi (recommended)
  • run on a server that you already pay for (be cautious as your passwords will be saved on the computer that you set the package up with)

How to install

Have Node.js installed. Run npm i -g drinking-code/cn-to-cal.
To uninstall, run npm uninstall -g cn-calendar.

Updating

From v1.0.0

If you have version 1.0.0 already installed and don't want to lose you configuration, copy it to /tmp like this (on Unix-based systems)

cp $(npm config -g get prefix)/lib/node_modules/cn-calendar/credentials.json /tmp/cn-calendar-data.json

Then run npm i -g drinking-code/cn-to-cal to install the newest version.

Special extra tip: If cn-calendar version returns Unknown command: 'version', you're on version v1.0.0

From v1.1.0 and up

Run cn-calendar update.

Usage

Although this packages does most things of the process automatically, there is a short setup you have to go through to use it properly.

Setup

Have an iCloud account. Open your console of choice and type cn-calendar setup.
You can create an app specific password by signing in to the Apple ID account page. Then under "Security" > "App Specific Passwords" click "Create password..." and follow the steps.
To get the next three values required go to https://icloud.com/calendar/, create a clean calendar ["Edit" -> "+"] and select it. (It is important that this calendar is not used by / for anything but this package.) Open your developer tools and go to the network tab (you might have to refresh the page to have all info shown correctly). Locate the entry named "startup" and find the following 3 values:

  1. the two digits after the "https://p" in the URL Screenshot 1
  2. the DSid (located in the parameters of the request) and Screenshot 2
  3. the pGuid (located in the response of the server) Screenshot 3

Starting

To start, type cn-calendar or cn-calendar run. Use the flag --once to run the script once (and not perpetually, twice every day). To see the log for the current process, type cn-calendar log. This log is deleted every time you start the package.

Stopping

To stop, type cn-calendar stop.

Reference

usage: cn-calendar [<command>] [<args>]
commands:
    setup [-y]                          prompts all requred values
    run [-q|--quiet] [--once] [-y]      starts the script
    stop                                stops the script
    log                                 prints the log of the current script
    version                             prints the version you have installed
    update                              updates to the latest version
options:
    -q, --quiet                         shows only prompts and errors
    --once                              runs the script only once and not on an interval
    -y                                  confirms all prompts
    -v, --version                       alias to the version command. Only use without a
                                        command, and without another flag

Contributing

This package currently only works with Apple Calendar. However, not all people use Apple Calendar as their primary calendar. Help to enable them using this package with their favourite calendar app.
This is the current state:

Calendar Supported Notes
Apple Calendar
Google Calendar Google API not suitable for small projects
Microsoft Calendar / Outlook
others?

To understand the code and contribute, refer to contributing.md

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors