Commit ccc2d285 authored by fuzzle's avatar fuzzle

add rdate, rrule like weekly monthly yearly still missing, remove some quotes,...

add rdate, rrule like weekly monthly yearly still missing, remove some quotes, add link to description for better usage in nextcloud (which doesnt show link by default)
parent 0c7fec10
......@@ -26,7 +26,7 @@ r = http.request("GET", url)
soup = BeautifulSoup(r.data, 'html.parser')
# just some feedback
print soup.title.string
print str(soup.title.string)
#print soup.select_one(".field--name-title").string
print ("#####")
......@@ -74,6 +74,11 @@ try:
except:
xxdate = soup.time.attrs['datetime']
# get endtime, should be second time tag
try:
xxdateend = soup.find_all('time')[1].attrs['datetime']
except:
None
# get geojson
......@@ -116,24 +121,45 @@ cal = Calendar()
event = Event()
event.add('summary', soup.title.string)
event.add('dtstart', datetime.strptime(xxdate, "%Y-%m-%dT%H:%M:%SZ"))
event.add('dtend', (datetime.strptime(xxdate, "%Y-%m-%dT%H:%M:%SZ") + timedelta(hours=1)))
try:
event.add('dtend', (datetime.strptime(xxdateend, "%Y-%m-%dT%H:%M:%SZ")))
except:
event.add('dtend', (datetime.strptime(xxdate, "%Y-%m-%dT%H:%M:%SZ") + timedelta(hours=1)))
# dtstamp should be "now"
# event.add('dtstamp', datetime(now, "%Y-%m-%dT%H:%M:%SZ"))
event.add('dtstamp', datetime.strptime(xxdate, "%Y-%m-%dT%H:%M:%SZ"))
# do rdate if given
# TODO : weekly / monthly events with rrule
try:
# get only every second element of list
# and make rfc conform rdate element
# actually not all used - should generate a rdate;value=period:20191212T010101/20101212T010102
for k,i in enumerate(soup.find_all('time')[0::2]):
#actually not used - should generate a rdate;value=period:20191212T010101/20101212T010102
# von = (datetime.strptime((i.attrs['datetime']), "%Y-%m-%dT%H:%M:%SZ")) #) #+"/"+(str(
# bis = (datetime.strftime((soup.find_all('time')[k+1].attrs['datetime']), "%Y-%m-%dT%H:%M:%SZ")) #) #))
# von = i.attrs['datetime']
# bis = soup.find_all('time')[k+1].attrs['datetime']
# vonbis = str((str(von) + "/" + str(bis)))
event.add('rdate', datetime.strptime((i.attrs['datetime']), "%Y-%m-%dT%H:%M:%SZ"), parameters={'VALUE': 'DATE-TIME'})
except:
None
event.add('transp', "TRANSPARENT")
event.add('tzid', "Europe/Berlin")
event.add('CATEGORIES', cat)
event.add('class', "PUBLIC")
event.add('description', xxdesc)
event.add('location', "\""+xxlocation+"\"")
event.add('description', xxdesc+"\n"+url)
event.add('location', xxlocation)
# try add GEO Tag
try:
event.add('geo', (geolat, geolon))
except:
print "no geodata (lat,lon) found"
event.add('url', "\""+url+"\"")
event.add('url', url)
# nextcloud need a uid for valid multievent ics files
event.add('uid', "\""+url+"\"")
# if random you quickly get duplicate dates
event.add('uid', url)
cal.add_component(event)
......
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