Skip to content

fontlos/buaa-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

452 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BUAA API

An all in one library. Aim To Make BUAA Great Again

注: 本项目只用于学习分享, 请于下载后 24 小时内删除, 使用产生的一切问题由使用者自行承担, 如有侵权我将删除此储存库和软件

Tips: This project is only for learning and sharing, please delete within 24 hours after downloading, all problems caused by the use are borne by the user, if there is any infringement I will delete this repository and software

TodoList

  • BUAA SSO: sso
    • Login: built in Context
  • BUAA Academic Affairs System: aas
    • Login
    • Get config
    • Query week schedule
    • Query term schedule
    • A universal request API for extensions
  • BUAA APP: app
    • Login
    • Get exam schedule
    • A universal request API for extensions
  • BUAA Boya Course: boya
    • Login
    • Get current semester
    • Query courses list
    • Query single course info
    • Query selected courses
    • Query statistic information
    • Select course
    • Drop course
    • Checkin course
    • Checkout course
    • A universal request API for extensions
  • BUAA Smart Classroom: class
    • Login
    • Query schedule by date
    • Query course list
    • Query course schedule
    • Checkin class
  • BUAA Cloud Disk: cloud
    • Login
    • Dir & File
      • Get root dir
      • Get user root dir
      • List dir
      • Get item size
      • Get suggest name
    • CRUD
      • Create dir
      • Rename item
      • Move item
      • Copy item
      • Delete item
    • Recycle Bin
      • List
      • Delete
      • Restore
    • Share
      • Share history
      • Share record of one item
      • Share item
      • Share update
      • Share delete
      • Share parse
    • Download
      • Get single item download URL (Auto make zip for dir)
      • Get a batch of items download URL (Auto make zip for dir or files)
    • Upload item
      • Upload fast check
      • Upload fast (Check success)
      • Upload small file
      • Upload big file (Over 5 GiB)
  • BUAA Classroom Live Broadcast (Spoc): live
    • Login
  • BUAA Spoc Platform: spoc
    • Login
    • Query teaching week
    • Query weekly schedule
    • Query courses
    • Homework
      • Query list
      • Query detail
      • Submit
    • Upload file (Authless) (Optional with progress)
    • A universal request API for extensions
  • BUAA Undergraduate & Graduate Student Course Registration System: srs
    • Login
    • Get config
    • Get batch
    • Query courses with filter
    • Query pre-selected courses
    • Query selected courses
    • Pre-select course
    • Select course
    • Drop course
  • BUAA Teaching Evaluation System: tes (Warning!!! See docs!)
    • Login
    • Get list
    • Get form
    • Submit form
  • User Center: user
    • Login
    • Get state
    • Change password
  • BUAA WiFi: wifi
    • Login
    • Logout
    • Recharge

APIs not listed above might have been overlooked or deemed unimportant by me, but if you need them, feel free to open an issue or open a pull request.

Usage

The basic process is:

  • Initialize the Context
    • (Optional) Set account
    • (Optional) Specifies the dictionary for auth
    • (Auto default) Login to SSO (Context)
  • Get the API group you need
    • (Auto default) Login to this group
  • Call API in this group
  • (Optional) Save auth file

There are some simple examples:

use buaa_api::Context;

#[tokio::main]
async fn main() {
    // Initialize the `Context`
    let context = Context::new();
    // Set account
    context.set_account("username", "password");
    // Login to context, and it will auto refresh by default
    // context.login().await.unwrap();

    // Get an API Group
    let user = context.user();
    // Login to this group, and it will auto refresh by default
    // user.login().await.unwrap();

    // Call API in this group
    let state = user.get_state().await.unwrap();
    println!("{}", state);
}
use buaa_api::Context;

#[tokio::main]
async fn main() {
    let context = Context::with_auth("./data").unwrap();

    let boya = context.boya();
    // You can manually relogin in advance.
    // This is useful to prevent login invalidation when grabbing a course
    boya.login().await.unwrap();

    let course_list = boya.query_course().await.unwrap();
    println!("{}", course_list);

    // Waiting until course can be selected ...

    let id = course_list[0].id; // Just an example
    let res = boya.select_course(id).await.unwrap();
    println!("{}", res);

    context.save_auth().unwrap();
}

BUAA WiFi is independent of other APIs and does not require cookies or Context.login():

use buaa::Context;

#[tokio::main]
async fn main() {
    let context = Context::new();
    context.set_account("username", "password")
    let wifi = context.wifi();
    // Login to BUAA WiFi
    wifi.login().await.unwrap();
    // Logout to BUAA WiFi
    wifi.logout().await.unwrap();
}

More usage see examples

About

BUAA API. An all in one library. Make BUAA Great Again

Resources

License

Stars

26 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages