8000 Added a way to get the current pronote week. by Apllify · Pull Request #53 · LelouBil/PronoteLib · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Aug 17, 2023. It is now read-only.

Added a way to get the current pronote week. #53

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ Pour récupérer les devoirs:
List<Homework> homework = obj.getHomeworkList(numerosemaine);
```

Pour récupérer le numéro de la semaine actuelle :
```Java
int numerosemaine = obj.getCurrentWeek();
```

ou url est le lien vers la page élève du serveur PRONOTE
ex : https://demo.index-education.net/pronote/eleve.html

Expand Down
25 changes: 24 additions & 1 deletion src/main/java/net/leloubil/pronotelib/AuthManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import java.util.HashMap;
import java.util.Random;

import java.time.LocalDate;

import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
Expand All @@ -35,6 +37,11 @@ class AuthManager {
}

private PronoteConnection obj;
private LocalDate firstMonday;

public LocalDate getFirstMonday() {
return firstMonday;
}

private byte[] debyte(byte[] b) {
String s = new String(b);
Expand Down Expand Up @@ -140,7 +147,23 @@ private String encryptaes(byte[] plaintext, byte[] key) throws GeneralSecurityEx
void sendIv(String mr, String er) throws GeneralSecurityException {
HashMap<String, Object> s = new HashMap<>();
s.put("Uuid", getUUID(mr, er));
obj.appelFonction("FonctionParametres", s);
JsonNode response = obj.appelFonction("FonctionParametres", s);
iv = tempIv;

String stringFirstMonday = response.get("donneesSec")
.get("donnees")
.get("General")
.get("PremierLundi")
.get("V")
.toString();



int firstMondayDay = Integer.parseInt(stringFirstMonday.substring(1, 3));
int firstMondayMonth = Integer.parseInt(stringFirstMonday.substring(4, 6));
int firstMondayYear = Integer.parseInt(stringFirstMonday.substring(7, 11));

firstMonday = LocalDate.of(firstMondayYear, firstMondayMonth, firstMondayDay);

}
}
11 changes: 11 additions & 0 deletions src/main/java/net/leloubil/pronotelib/PronoteConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;

@SuppressWarnings({ "SameParameterValue", "UnusedReturnValue" })
public class PronoteConnection {

Expand Down Expand Up @@ -296,4 +299,12 @@ private void setUrl(String url) {
portalUrl = url;
apiUrl = url.replace("eleve.html", "appelfonction/3/");
}


public int getCurrentWeek() {
LocalDate firstMonday = authManager.getFirstMonday();
LocalDate currentDate = LocalDate.now();

return 1 + (int)ChronoUnit.WEEKS.between(firstMonday, currentDate);
}
}
0