Crates.io | dnevnik |
lib.rs | dnevnik |
version | 0.3.6 |
source | src |
created_at | 2022-10-02 18:34:58.987794 |
updated_at | 2022-10-03 19:58:50.560301 |
description | dnevnik.mos.ru Internal API Wrapper |
homepage | |
repository | https://github.com/Maxuss/dnevnik |
max_upload_size | |
id | 678509 |
size | 45,083 |
A rust API wrapper for accessing the https://dnevnik.mos.ru internal API
All API info was gathered by reverse engineering the network requests.
use dnevnik::prelude::*;
// assuming you are using tokio, anyhow and chrono
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let auth_token: String = "Your auth token";
let diary: Diary = Diary::new(auth_token).await?;
let student_profile: StudentProfile = diary.profile;
// Gets homework for the last week
let homework: Vec<StudentHomework> = diary.homework(
Utc::now() - Duration::days(7),
Utc::now()
).await?;
// Downloads all attachment files from this homework
homework.iter().for_each(|hw| {
if !hw.homework_entry.attachments.is_empty() {
let attachment: &HomeworkAttachment = &hw.homework_entry.attachments[0];
println!(
"Downloading attachment for {} (path: {})",
hw.homework_entry.subject().name,
attachment.file_name
);
let path: PathBuf = PathBuf::from(&attachment.file_name);
diary.download_attachment(path.clone(), attachment).await?;
}
});
Ok(())
}
More examples are TBD