summaryrefslogtreecommitdiff
path: root/school/node_modules/pronote-api/bin
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2023-02-23 19:34:56 +0100
committerMinteck <contact@minteck.org>2023-02-23 19:34:56 +0100
commit3d1cd02f27518f1a04374c7c8320cd5d82ede6e9 (patch)
tree75be5fba4368472fb11c8015aee026b2b9a71888 /school/node_modules/pronote-api/bin
parent8cc1f13c17fa2fb5a4410542d39e650e02945634 (diff)
downloadpluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.tar.gz
pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.tar.bz2
pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.zip
Updated 40 files, added 37 files, deleted 1103 files and renamed 3905 files (automated)
Diffstat (limited to 'school/node_modules/pronote-api/bin')
-rwxr-xr-xschool/node_modules/pronote-api/bin/fetch.js120
-rwxr-xr-xschool/node_modules/pronote-api/bin/server.js19
-rw-r--r--school/node_modules/pronote-api/bin/test.js13
3 files changed, 0 insertions, 152 deletions
diff --git a/school/node_modules/pronote-api/bin/fetch.js b/school/node_modules/pronote-api/bin/fetch.js
deleted file mode 100755
index d9e88e7..0000000
--- a/school/node_modules/pronote-api/bin/fetch.js
+++ /dev/null
@@ -1,120 +0,0 @@
-#!/usr/bin/env node
-
-/* eslint no-console: off */
-
-const fs = require('fs').promises;
-const pronote = require('..');
-
-if (process.argv.length < 5) {
- console.log('Syntax: pronote-fetch <URL> <username> <password> [cas(ex: none)] [AccountType (ex: Student)]');
- return;
-}
-
-const [,, url, username, password, cas = 'none', accountType] = process.argv;
-
-async function fetch()
-{
- let result;
- switch (accountType)
- {
- case 'parent':
- result = await parent();
- break;
- default:
- result = await student();
- break;
- }
-
- await fs.writeFile('result.json', JSON.stringify(result, null, 4));
-
- console.log('Wrote \'result.json\'');
-}
-
-async function student()
-{
- const session = await pronote.login(url, username, password, cas);
- console.log(`Logged as student '${session.user.name}' (${session.user.studentClass.name})`);
-
- const { from, to } = getFetchDate(session);
-
- const timetable = await session.timetable(from, to);
- const marks = await session.marks();
- const evaluations = await session.evaluations();
- const absences = await session.absences();
- const infos = await session.infos();
- const contents = await session.contents(from, to);
- const homeworks = await session.homeworks(from, to);
- const menu = await session.menu(from, to);
- const files = await session.files();
-
- return {
- name: session.user.name,
- studentClass: session.user.studentClass.name,
- avatar: session.user.avatar,
-
- timetable, marks, evaluations, absences,
- infos, contents, homeworks, menu, files
- };
-}
-
-async function parent()
-{
- const session = await pronote.loginParent(url, username, password, cas);
- console.log(`Logged as parent '${session.user.name}' (${session.user.students.length} students)`);
-
- const { from, to } = getFetchDate(session);
-
- const students = [];
- for (const student of session.user.students) {
- console.log(`Fetching data of user '${student.name}' (${student.studentClass.name})`);
-
- const timetable = await session.timetable(student, from, to);
- const marks = await session.marks(student);
- const evaluations = await session.evaluations(student);
- const absences = await session.absences(student);
- const infos = await session.infos(student);
- const contents = await session.contents(student, from, to);
- const homeworks = await session.homeworks(student, from, to);
- const menu = await session.menu(student, from, to);
- const files = await session.files(student);
-
- students.push({
- name: student.name,
- studentClass: student.studentClass.name,
- avatar: student.avatar,
-
- timetable, marks, evaluations, absences,
- infos, contents, homeworks, menu, files
- });
- }
-
- return {
- name: session.user.name,
- students
- };
-}
-
-function getFetchDate(session)
-{
- let from = new Date();
- if (from < session.params.firstDay) {
- from = session.params.firstDay;
- }
-
- const to = new Date(from.getTime());
- to.setDate(to.getDate() + 15);
-
- return { from, to };
-}
-
-fetch().catch(err => {
- if (err.code === pronote.errors.WRONG_CREDENTIALS.code) {
- return console.error('Invalid credentials, did you chose the right CAS ?');
- }
-
- if (err.code !== undefined) {
- console.error(`ERROR: [${err.code}] ${err.message}`);
- } else {
- console.error(err);
- }
-});
diff --git a/school/node_modules/pronote-api/bin/server.js b/school/node_modules/pronote-api/bin/server.js
deleted file mode 100755
index c5d3c5d..0000000
--- a/school/node_modules/pronote-api/bin/server.js
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/env node
-
-/* eslint no-console: off */
-
-const server = require('../src/server');
-
-if (process.argv.length === 2 && process.argv[1] === '--help') {
- console.log('Syntax: pronote-api-server [port (default: 21727)] [host (default: 0.0.0.0)]');
- return;
-}
-
-const [,, port = '21727', host = '127.0.0.1'] = process.argv;
-
-server(host, port).then(() => {
- console.log(`--> Listening on ${host}:${port}`);
-}).catch(err => {
- console.error('Error during server start');
- console.error(err);
-});
diff --git a/school/node_modules/pronote-api/bin/test.js b/school/node_modules/pronote-api/bin/test.js
deleted file mode 100644
index 22b43bf..0000000
--- a/school/node_modules/pronote-api/bin/test.js
+++ /dev/null
@@ -1,13 +0,0 @@
-const { fork } = require('child_process');
-const { join } = require('path');
-
-const DEMO_URL = 'https://demo.index-education.net/pronote/';
-const DEMO_USERNAME = 'demonstration';
-const DEMO_PASSWORD = 'pronotevs';
-
-function test(type)
-{
- fork(join(__dirname, 'fetch.js'), [DEMO_URL, DEMO_USERNAME, DEMO_PASSWORD, 'none', type], { stdio: 'inherit' });
-}
-
-['student', 'parent'].forEach(test);