ubs-lib

a library for fetching real-time University at Buffalo class schedules

2 releases

0.1.1 Aug 5, 2023
0.1.0 Aug 5, 2023


Used in ubs

MIT license

43KB
754 lines

ubs

University at Buffalo Schedule

test docs crates discord

ubs is a library designed to provide real-time access to University at Buffalo class schedules, offering a wealth of information on each class. This includes: class open/closed, start/end date, start/end time, class type, class id, section, room, instructor, seats open/closed, etc.

Installation

Cargo

$ cargo install ubs

Examples

Below is a snippet of using the high-level API with tokio for fetching live class information.

use futures::stream::TryStreamExt;
use ubs_lib::{Career, Course, Semester};

#[tokio::main]
async fn main() -> Result<(), ubs_lib::Error> {
    let mut schedule_iter = ubs_lib::schedule_iter(
        Course::Cse115,
        Semester::Spring2023,
    ).await?;

    while let Some(schedule) = schedule_iter.try_next().await? {
        for group in schedule?.group_iter() {
            for class in group.class_iter() {
                // do stuff
            }
        }
    }

    Ok(())
}

FAQ

How does it work?

The process involves sending a precisely tailored sequence of network requests directed towards the target URL. Upon receiving the requests, the resulting HTML is cached until the user requests specific information, at which point it is parsed to specification and the inner values are extracted using Regex.

Could I use this library from other languages?

Yes. While direct access to the core library may not be possible from other languages (yet), the library does provide a command-line interface that can output data in the desired format.

How stable is this library?

Sort of stable. While using this library, it's important to note that there is a possibility that the underlying API may change in the future. Therefore, it may not be advisable to depend on this library for critical code. However, the library does have a comprehensive continuous integration system that runs daily, catching potential issues early on. In the event that the API does change and ubs ceases to function properly, users are encouraged to report the issue so that it can be resolved.

Does this library operate on private information?

No, this library operates exclusively on public information that is readily accessible to anyone. There are no proprietary or confidential data sources involved.

Dependencies

~8–19MB
~270K SLoC