timoschlueter / RocketBeans.TV-Sendeplan

Diese App zeigt den aktuellen Sendeplan von RocketBeans.TV in der Menüleiste von Mac OS X an.
MIT License
12 stars 5 forks source link

Parsing ICS instead of XML #13

Closed timoschlueter closed 9 years ago

timoschlueter commented 9 years ago

I am currently trying to parse the ICS file provided by Google. As @timbooo already mentioned: The XML file Google provides is plain stupid. Since day one of this App i had to parse strings into dates which is never a good idea.

I wrote a ICS parser a few years ago in python and i will try to port it to swift. I haven't found any good ICS parsers we can use out of the box so i guess we will have to do it ourselves.

Here is an example of a single event in ICS format. I think that this would be way easier to work with, especially with the timestamps.

BEGIN:VEVENT
DTSTART:20150116T163000Z
DTEND:20150116T173000Z
DTSTAMP:20150125T121641Z
UID:0nodpuvtjm8n55ncuv6kf9c4fc@google.com
CREATED:20150116T150235Z
DESCRIPTION:
LAST-MODIFIED:20150116T150235Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Baking Bad
TRANSP:OPAQUE
END:VEVENT
timoschlueter commented 9 years ago

I made some progress parsing the ICS:

30 Sekunden über Silvester: (Start: 20150117T145500Z / End: 20150117T151500Z)
Politik Simulator: (Start: 20150117T061500Z / End: 20150117T081500Z)
Almost Daily Classics: (Start: 20150117T050000Z / End: 20150117T060000Z)
RB News: (Start: 20150117T230000Z / End: 20150117T231500Z)
Stumble TV #01: (Start: 20150117T210000Z / End: 20150117T220000Z)
Shenmue 2 Das Ende: (Start: 20150117T180000Z / End: 20150117T210000Z)
Erwachsene Männer.....: (Start: 20150117T220000Z / End: 20150117T230000Z)
30 Sekunden: (Start: 20150116T173000Z / End: 20150116T180000Z)
Baking Bad: (Start: 20150116T163000Z / End: 20150116T173000Z)
Brett & Breakfast: (Start: 20150116T141500Z / End: 20150116T144500Z)

Its not a fully functional ICS parser but it extracts everything embedded inside "BEGIN:VEVENT" and "END:VEVENT". According to the RFC for ICS, the Timestamps are always the same format and in the UTC timezone.

der-tkw commented 9 years ago

Does the iCal contain "Pen & Paper 3" and/or "Kino +"? - It seems that the XML file doesn't. Those programs are missing, and therefore there are large gaps.

timoschlueter commented 9 years ago

Looks like it does:

After Dark: (Start: 20150125T103000Z / End: 20150125T120000Z)
Straight 2 Gold (SC2): (Start: 20150125T120000Z / End: 20150125T130000Z)
Schröcks Fernsehgarten: (Start: 20150125T130000Z / End: 20150125T131000Z)
-->  Pen & Paper 3: (Start: 20150125T131000Z / End: 20150125T170000Z) <--
Kino+: (Start: 20150125T170000Z / End: 20150125T190500Z)
[N] Mate Knights #2: (Start: 20150125T190500Z / End: 20150125T200000Z)
Almost Daily: (Start: 20150125T200000Z / End: 20150125T210000Z)
[N] Spiele mit Bart: (Start: 20150125T211000Z / End: 20150125T230000Z)
[L] Wir müssen Reden #2: (Start: 20150126T210000Z / End: 20150126T230000Z)

Is it visible in the plain XML file or is it a parsing error again?

der-tkw commented 9 years ago

I curled the URL directly and couldn't find it. Don't know the reason though.

Am 25.01.2015 um 15:56 schrieb Timo Schlüter notifications@github.com:

Looks like it does:

After Dark: (Start: 20150125T103000Z / End: 20150125T120000Z) Straight 2 Gold (SC2): (Start: 20150125T120000Z / End: 20150125T130000Z) Schröcks Fernsehgarten: (Start: 20150125T130000Z / End: 20150125T131000Z) --> Pen & Paper 3: (Start: 20150125T131000Z / End: 20150125T170000Z) <-- Kino+: (Start: 20150125T170000Z / End: 20150125T190500Z) [N] Mate Knights #2: (Start: 20150125T190500Z / End: 20150125T200000Z) Almost Daily: (Start: 20150125T200000Z / End: 20150125T210000Z) [N] Spiele mit Bart: (Start: 20150125T211000Z / End: 20150125T230000Z) [L] Wir müssen Reden #2: (Start: 20150126T210000Z / End: 20150126T230000Z) Is it visible in the plain XML file or is it a parsing error again?

— Reply to this email directly or view it on GitHub.

timoschlueter commented 9 years ago

I just committed a new version using ICS parsing: 9a2f7c9ad76be03f713fd25588f2ea1dd8d3ad35. I opened a new branch since my version may lack some features. I cleaned the code and while doing so i might have screwed up some parts of the earlier versions. Could you guys give this a review? I need a beer now :)

BlackWolf commented 9 years ago

Just want to add this is desperately needed, the XML seems to be majorly broken as of today, most of the program is missing for some reason. Seems to be a bug/error in google calendar, though?

I will give the ICS version a review later and report back.

BlackWolf commented 9 years ago

Most of it seems fine and the code is muuuch nicer now!

I do see an issue with times, though. For example, the app currently reports this: screen shot 2015-01-25 at 23 06 58

As you can see, "Spiele mit Bart" starts at 22:10. Actually, it starts at 23:00, though, which is also what the ics seems to report. I think the app is throwing together the last show that ran and the currently running show (because Mathe Knights, which ran before, started 22:10).

I couldn't find the culprit in code, but maybe someone else can.

Besides that, code and app look great!

timoschlueter commented 9 years ago

Thanks for the first review and the feedback! :) I looked into the code. I imported the ICS in my OS X Kalendar and compared it to the dates you mentioned but i can't find the problem just yet.

The calendar app shots "Spiele mit Bart" starting at 22:10 and so does our app. Or am i missing something? Its late, so i may be blind :)

bildschirmfoto 2015-01-25 um 23 26 11

BlackWolf commented 9 years ago

You are absolutely right... I looked at the ICS in a text editor, seems I got confused ^^ In that case, no errors found :D

timoschlueter commented 9 years ago

Great! So i guess i will merge into master, compile a binary and update the reddit-post. With ICS under control now, the future seems a bit brighter now :D

timoschlueter commented 9 years ago

Fixed in 072eb22943930e818a5e2d4484f1366137f321f3.