Browse Source

Va chercher sur NTNOE

master
Klafyvel 8 years ago
parent
commit
080c5aabff
  1. 27
      main.py

27
main.py

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

Loading…
Cancel
Save