LiterateInk / Pawnote

A purrfect API wrapper for Pronote.
https://literate.ink/pawnote
GNU General Public License v3.0
40 stars 7 forks source link

feat(timetable): add ical URL getter #39

Open Vexcited opened 1 week ago

Vexcited commented 1 week ago

get the URL for the ical that might be available in some instances that have the feature enabled (defaults to disabled according to people online)

Gabriel29306 commented 1 week ago

Dans la réponse à PageEmploiDuTemps, on retrouve ParametreExportiCaldonneesSec.donnees.ParametreExportiCal. Le format de l'url est instanceURL/pronote/ical/Edt.ics?icalsecurise=ParametreExportiCal&version=version&param=options

setLien(aSansRessource) {
const lSansRessource = !!aSansRessource ? aSansRessource : false;
    let lParams = 'fh=' + this.fuseauHoraire;
    if (!this.semainesPubliees) {
        lParams += '&d=' + GChaine.domaineToStr(GEtatUtilisateur.getDomaineSelectionne());
    }
    if (this.genreICal) {
        lParams += '&o=' + this.genreICal;
    }
    let lHref;
    let lInformationMasquee;
    if (!lSansRessource) {
        lHref = 'ical/' + this.getPrefixICal() + '.ics';
        lInformationMasquee = 'icalsecurise=' + this.ParametreExportICal + '&version=' + GParametres.versionPN;
    } else {
        lHref = 'ical/exportSalles.ics';
        lInformationMasquee = 'icalSansRessource=Salles&version=' + GParametres.versionPN;
    }
    lHref = lHref + '?' + (lInformationMasquee) + '&param=' + new forge.util.ByteBuffer(lParams).toHex();
    GHtml.setLien(this.idHrefICal, lHref);
    GHtml.setValue(this.idLienPermanent, GChaine.encoderUrl(GNavigateur.getHost() + lHref));
    $('#' + this.idQRCode.escapeJQ()).html(kjua({
        render: 'image',
        size: 175,
        text: GNavigateur.getHost() + lHref
    }).outerHTML);
}

this.fuseauHoraire à l'air d'être toujours à 1

setDonnees(aElement, aParametreExportICal, aGenreRessource, aDomaine, aFiltre, aSansRessource) {
    this.element = aElement;
    this.ParametreExportICal = aParametreExportICal;
    this.genreRessource = aGenreRessource;
    this.domaine = (aDomaine !== null && aDomaine !== undefined) ? aDomaine : 0;
    this.filtre = aFiltre;
    this.semainesPubliees = true;
    this.fuseauHoraire = this.getValeurFuseauHoraireParDefaut();
    this.setLien(aSansRessource);
    this.afficher();
}
getValeurFuseauHoraireParDefaut() {
    return 1;
}

D'après ce code, j'en déduis que EDT vaut 0 et Agenda vaut 1

;IE.fModule({
    f: function(exports, require, module, global) {
        const EGenreICal = {
            EDT: 0,
            Agenda: 1
        };
        module.exports = EGenreICal;
    },
    fn: 'enumere_ical.js'
});

Donc quand on veut récupérer pour l'edt, le paramètre &o= de options est omis.

Résumé:

On peut donc garder une version définitive de l'url: instanceURL/pronote/ical/Edt.ics?icalsecurise=ParametreExportiCal&version=version&param=66683d31 PS: On peut remplacé Edt.ics par Agenda.ics sans incidences.