|
|
|
@ -2,6 +2,8 @@ import datetime |
|
|
|
import httplib2 |
|
|
|
import urllib |
|
|
|
import os |
|
|
|
import requests |
|
|
|
import shutil |
|
|
|
|
|
|
|
from apiclient import discovery |
|
|
|
from oauth2client import client |
|
|
|
@ -95,21 +97,17 @@ def get_ntnoe(): |
|
|
|
url = "http://ntnoe.metz.supelec.fr/ical/EdTcustom/Eleves/edt_{}.ics" |
|
|
|
url = url.format(NTNOE_ID) |
|
|
|
|
|
|
|
h = httplib2.Http() |
|
|
|
h.add_credentials(NTNOE_ID,NTNOE_PASS) |
|
|
|
data = {'envoyer':'Utf8_All','submit':'G%E9n%E9rer'} |
|
|
|
data = {'envoyer':'Utf8_All','submit':'Générer'} |
|
|
|
|
|
|
|
h.request( |
|
|
|
r = requests.get( |
|
|
|
"https://ntnoe.metz.supelec.fr/ical/index.php", |
|
|
|
body=urllib.parse.urlencode(data), |
|
|
|
method='POST', |
|
|
|
data=urllib.parse.urlencode(data), |
|
|
|
auth=(NTNOE_ID, NTNOE_PASS), |
|
|
|
) |
|
|
|
# resp,content = h.request( |
|
|
|
# "https://ntnoe.metz.supelec.fr/ical/EdTcustom/Eleves/edt_{id}.ics".format(id=NTNOE_ID), |
|
|
|
# ) |
|
|
|
# print(resp,content) |
|
|
|
# TODO : download from ntnoe |
|
|
|
|
|
|
|
url = "https://ntnoe.metz.supelec.fr/ical/EdTcustom/Eleves/edt_{id}.ics".format(id=NTNOE_ID) |
|
|
|
r = requests.get(url, auth=(NTNOE_ID, NTNOE_PASS), stream=True) |
|
|
|
with open("edt_{}.ics".format(NTNOE_ID), 'wb') as f: |
|
|
|
f.write(r.content) |
|
|
|
|
|
|
|
|
|
|
|
def main(): |
|
|
|
@ -126,9 +124,10 @@ def main(): |
|
|
|
|
|
|
|
now = datetime.datetime.now() |
|
|
|
then = now + TIMEDELTA_SYNCHRO |
|
|
|
time_search = datetime.datetime(now.year, now.month, now.day, 1) |
|
|
|
response = service.events().list( |
|
|
|
calendarId='primary', |
|
|
|
timeMin=now.isoformat()+'Z', |
|
|
|
timeMin=time_search.isoformat()+'Z', |
|
|
|
timeMax=then.isoformat()+'Z', |
|
|
|
).execute() |
|
|
|
|
|
|
|
@ -149,8 +148,6 @@ def main(): |
|
|
|
|
|
|
|
if existing_events.intersection({event.summary}): |
|
|
|
continue |
|
|
|
else: |
|
|
|
print(event.summary) |
|
|
|
|
|
|
|
event = service.events().insert( |
|
|
|
calendarId='primary', |
|
|
|
|