Commit 33e8b9e0 authored by Vincent-Xavier JUMEL's avatar Vincent-Xavier JUMEL
Browse files

Ajout d'un code pour publier les documents sur ED

parent 11f37aad
Pipeline #339051 passed with stages
in 2 minutes and 43 seconds
......@@ -44,27 +44,25 @@ def put_seance(token, date, classe, contenu):
seance_info['seance']['modeEdit'] = "True"
seance_info['seance']['contenu'] = b64encode(bytes(contenu,'utf-8')).decode('utf-8')
data = f'data={json.dumps(seance_info)}'
r = requests.post(
context = requests.post(
f'https://apip.ecoledirecte.com/v3/cahierdetexte/seance/{classe}/{seance_info["matiereCode"]}/{date}.awp?verbe=put',
data=data
)
context = json.loads(r.text)['idCDT']
#data = f'data={'token':"{token}"}'
return context
def attach_document(token, document, context):
idContexte = json.loads(context.text)["data"]['idCDT']
boundary='---------------------------23681658131424797482946919298'
headers = {'Content-Type': 'multipart§/form-data; boundary={boundary}'}
data_binary = f"""{boundary}\r\n
Content-Disposition: form-data; name="data"\r\n\r\n{{'token':'{token}','idContexte':'{idContexte}','side':'seance'}}\r\n
Content-Disposition: form-data; name="file"; filename="{document}"\r\n
Content-Type: text/x-tex\r\n\r\n{boundary}--\r\n"""
r = requests.post('https://apip.ecoledirecte.com/v3/televersement.awp?verbe=post&mode=CDT',
# -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0',
# -H 'Accept: application/json' -H 'Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.5,en;q=0.3',
# --compressed,
# -H, 'Cache-Control: no-cache',
# -H 'X-Requested-With: XMLHttpRequest',
# -H 'Content-Type: multipart/form-data; boundary=---------------------------23681658131424797482946919298',
# -H 'Origin: https://www.ecoledirecte.com',
# -H 'DNT: 1',
# -H 'Connection: keep-alive',
# -H 'Referer: https://www.ecoledirecte.com/CahierDeTexte',
# -H 'Pragma: no-cache',
# --data-binary $'-----------------------------23681658131424797482946919298\r\nContent-Disposition: form-data; name="data"\r\n\r\n{"token":"513141304f45704453567042556b78595757564a5a6c4e59516d70715348686b634568684e487070655464314e6a6452525746345a576473516a68785255524b61544177654859335a307048633056460d0a625870426555784b56326c5856304e546356526a564578755a47454e436e55346546466c63584e6964334e6f5532745a536d31514d474645596d38346458706a4c30465854484d78655770546247517a0d0a615730344f55356b56575a754d6d787555454a344f474e4d5a6e4630646a55794d3256574f4852715648453265554658636c684b646c6c7544517077525468325a3068755132704c515468304f4670610d0a593063774d574d776331465a6330784451574a7a63554a6f5a445a554c30553153335a454f4559794e48564e52564268646d646d54444535526a56544f586c34627a42744d7a4a77526e68434e3074320d0a59586c766267304b616c4d306447314b4f584e334d45746c566b3953536c705063324e7859326c355a444a4952554677566c464f64314e32656e6455636e427959545658566e4234556b4572616a42530d0a4d4735594f466c4b55464633646b5643637939686447316e575468314d6c42585755634e436e683459546469546c526a4c30637a575574435a6a523162564a6c4d326f30526d78735a574e324d4864560d0a596c464a64546c555a315249626c4e775a484e51516a42734e57316c65537471574851326330356e61566c4d646c7076566b3550636e464252464a77513046474451704462455a50556b5531654374730d0a64325a575a4642684e3039444d4855785633677a51303131646b59355132453152544d326258464b4d79397151336b7a555442495332394d616d685a52465a5456325678613046444e546c4d4e5752520d0a63546875626a424f4e4441315451304b623046366255466e4f574a735a45316d51576c614b30786b626c564251554530616e68555a6c6c32547a4133636c637a64484270636e6843635468495a3152420d0a4d6d3573647a6c6a6332686c53334657613070754b3277784e4535735654566b59326858576b59334d6e634e436e553356564e4a635564355655397a5455677a516b4e4e4d6a6779646e7033613051720d0a526d31535532784c54564d3465485a4f636b383062575649576e5a6c5233564b4f57316b556a52614e6c4635547a6c3463334e5a546c63304e6d673163307330526a526d626d464444517034616b35570d0a566974795930706b4d6d565556437479597a4e7252304a6b647a646f53484a4653334646646b644f656e52316445395351564a4b646d59324c7a4e585648684c615646705a6c5a48615867344d3078590d0a5a546472566d4e774e6e6c35556a4a565a7a41796267304b56486c69516a6778523239745a6c517a56566833616d56454e456876596a644a646c5534633370596233526c4e564249516b3956646b70330d0a4d4870336448633562316c43567a4e52523077334b30316862555a6f4d6a4e77616e704851565a36536e4e70596d6c515448634e436d31326130397252564a465647744a4d7a4e33576c4675516e56680d0a5645744559323879633239744e6c5978616b706d56446c7751335a34595373764d6d396c55476b724f5464715744465352476846556c4649567a644b5a58684c57545676546b354b4f464a3663334e580d0a44516f72567a564d4e5539306553396d4d486c734d45316f63555235626b78495a305a55524646466230704f595468744e6b5a34574642756557526c636e684d554670544d48645a4f464e57564656610d0a5a55787259576452546e4a364f576c474e445a535a326f76646c644d5541304b63487034593046535956417754475268616a4a774e4452316554525a5156705064475532556b4656626c417763474e6a0d0a5a6e413553797475516b4e6e55564a7754575655575842355a5656616358564e636d464a556d6477546c52785257517253584a6f6248525055456b4e436d6c4b62473551566d52616433526c575846730d0a62545a754e584a744d6d34794d6d6c544f5664334d585a7a53455272516a647053545533547a4a71513146465645466f4d6e527255304a545458704d56484578616e4254526b5650636b6435595856730d0a54584a6e4e6b647444516f725245526e65444d316231564856584e5353326731543352704e5442546347777255486c7162437457566d3134544855346246686b546b7877625452304d3370555a486c4c0d0a56474e5a597a413353546445596b3144556e4535647a67764d6d7878515855324f5842545251304b6357745664326c524e793945555851335543744b5a55733255315a6d4d314a545455686d624456480d0a5757647463555134636e4a7852314269566b4a34576b553364456475523142614b334661545735596154686f6145686155457032566c564a6248704b616d464d6547514e436e4659596b7868565574610d0a5348524b4d486c7a6232453363586c6a616a4d77516a4261516b5233536b56324d6b316c5433564a556d4e4d5a327444557a424f56486f7265586f7252484e4e4e3268716379746851306c57636c4a4b0d0a644451326354686d513352736331517744517077656d30334f456b355133525a4d6b49784d5642475345396c4f486845554751306556425a4d3077355755317357437457553046315457683464586b310d0a566c4e4e5746427a5545395a61544a77537a424c614574494e6b70596358706c656d78565a454d7962576c6f6151304b4d32786d5131413254555572556c686b53307436516d78714d464a4a5331526d0d0a5247685662307031646b35455a7a644f546a6c785a7a633563314a7463486843624664495332745656337069546c70304d6a4e4259316c4f516b466e556c706f5645773263584a515746634e436e6f720d0a4e6a6b764e334a565a54647a51575a5951326c7a646c4a444e445a7254457442","idContexte":1214,"side":"seance"}\r\n-----------------------------23681658131424797482946919298\r\nContent-Disposition: form-data; name="file"; filename="raisonnement_absurde_un_tiers_nest_pas_decimal.tex"\r\nContent-Type: text/x-tex\r\n\r\n-----------------------------23681658131424797482946919298--\r\n'
headers=headers,
data=data_binary
)
return r
if __name__ == '__main__':
......@@ -74,6 +72,8 @@ if __name__ == '__main__':
with open('compile.csv','r') as fp:
fichiers = csv.DictReader(fp, delimiter=';')
for seance in fichiers:
put_seance(token, seance['dates'], seance['classe'], seance['message'])
context = put_seance(token, seance['dates'], seance['classe'], seance['message'])
documents = seance['fichiers'].split(' ')
for document in documents:
attach_document(token, document, context)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment