lu-schedule
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

lu-schedule

npm version

Node.js API for interacting with Lunds Universitets TimeEdit schedule

Features

  • Get schedule from URL
  • Automatically parses student groups
  • Zero dependencies
  • Cross platform - Runs on both Node.js and in the browser

Installing

Using npm:

$ npm install lu-schedule

Using yarn:

$ yarn add lu-schedule

Using script tag:

<script src="lu-schedule.min.js"></script>

Example

Retrieving a schedule from URL

const { Schedule } = require('lu-schedule')
 
const schedule = Schedule.fromUrl('https://cloud.timeedit.net/lu/web/m1/ri14750Yg50003Q0g2QY61l4Z762X653760Y540yZ05QZ5Q6Qu496ZpQc.html')
 
// ES6 async await. Remember to use the `async` keyword.
async function myFunction () {
  try {
    await schedule.load()
    console.log(schedule.lessons)
  } catch (error) {
    console.error(error)
  }
}
 
// Standard promises
schedule.load()
  .then(function (schedule) {
    console.log(schedule)
  })
  .catch(function (error) {
    console.error(error)
  })
 

Schedule object data (with data from the example above)

{
  programmeId: 'm1',
  id: 'ri14750Yg50003Q0g2QY61l4Z762X653760Y540yZ05QZ5Q6Qu496ZpQc',
  issuer: 'Lunds universitet',
  filter: 'M-RoN, RoN',
  span: '2019-09-02 - 2020-01-19 v 36-3',
  lessons: [
    {
      start: '2019-09-05T11:00:00.000Z', // Date object
      end: '2019-09-05T13:00:00.000Z', // Date object
      course: 'M-RoN',
      studentGroups: {
        groups: []
      },
      subGroups: {
        groups: [
          { course: 'M-RoN', groupName: 'gr.09-10', groupNumbers: [9, 10] },
          { course: 'M-RoN', groupName: 'gr.13-14', groupNumbers: [13, 14] }
        ],
        // All group numbers combined. Will only be set if any of the sub groups have groupNumbers.
        groupNumbers: [9, 10, 13, 14]
      },
      student: '',
      subCourse: '',
      educationalType: 'GrpDemo',
      title: 'CNS 1',
      location: 'BMC I 1129 Mod 2, BMC I 1136 Mod 4',
      locationComment: '',
      locationBooking: '',
      educator: '',
      externalEducator: '',
      comment: '',
      url: '',
      reason: '',
      count: '',
      id: '2037000'
    },
    ... // Only showing one lesson here.
  ]
}

TypeScript

lu-schedule comes with TypeScript definitions.

Licence

MIT

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.40latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.40
1.0.30
1.0.20
1.0.10

Package Sidebar

Install

npm i lu-schedule

Weekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

684 kB

Total Files

30

Last publish

Collaborators

  • script_coded