Parser for XMLTV format and SchedulesDirect data

For a long time now, I’ve been a paying customer of SchedulesDirect, and by that token their parent company Zap2it (now a Tribune Media Services company).
Recently, I’ve started publishing my own personal Electronic Programming Guide (EPG) here on BCmoney MobileTV in an accessible format:
BC$ EPG
One of the secondary goals of my MobileTV project has always been to be able to provide all XMLTV users a venue to easily access and conveniently plan/schedule their TV viewing via the web, on a variety devices (i.e. mobiles/tablets/desktop computers).
Soon I’ll be adding in a User Management feature that allows you to signup for SchedulesDirect and synch your account through BC$, and most importantly, protect your EPG and viewing data by your username and password (this is required to meet the SchedulesDirect usage terms and privacy policy).
I found that GET requests are not supported so technically the Tribune Web Service must still be following the SOAP 1.1 not SOAP 1.2 standard which specifies both GET and POST are acceptable as long as the SOAP request enveloppe is passed via URL.
Since that is not supported, you have to use POST and it also has to have the BASIC authentication information included in the header in the exact pattern:
Authorization: BASIC xxxxxxxxxxxxxxxxxxxxxxxxx
where:
xxxxxxxxxxxxxxxxxxxx = base64encoded(username:password)
Don’t forget the semicolon as a string in between the username and password (like I did at first)!
Before any programming, try debugging using a SOAP tool… it DEFINITELY helps save sanitiy. I got it working using SOAP UI: http://soapui.org/
You need to do the following in SOAP UI:
- File –> New SoapUI Project
- Name it “SchedulesDirect” or something the like…
- Paste in the WSDL location “http://docs.tms.tribune.com/tech/tmsdatadirect/schedulesdirect/tvDataDelivery.wsdl”
- Check “Create TestSuite” and “TestCase”
- Expand the project, Under “xtvdBinding” there should be a “download” Web Service call stub, expand that and open Request 1
- Click the little “Auth” tab at the bottom of the Request window (easy to miss… look down next to “Headers” and “Attachments” tabs)
- Enter your SchedulesDirect username and password, then click the little green “Run” arrow at the top left of the Request window
With the initial testing out of the way as a “sanity check” on your SchedulesDirect account, you can now get started on the coding.
TMS Direct Download script
In the meantime, here’s a modified version of “tmsfetch.php” which was initially provided by SchedulesDirect as one of the official examples:
<?php $username='username'; $password='password'; $wsdl_url='http://docs.tms.tribune.com/tech/tmsdatadirect/schedulesdirect/tvDataDelivery.wsdl'; $start=gmdate("Y-m-dTH:i:sZ",time()); //today $stop =gmdate("Y-m-dTH:i:sZ",time()+3600*24); //tomorrow (now + 24hrs) $client = new SoapClient($wsdl_url, array('exceptions' => 0, 'user_agent' => "php/".$_SERVER[SCRIPT_NAME], 'login' => strtolower($username), 'password' => $password)); $data = $client->download($start,$stop); print_r($data); ?>
-or-
UPDATE (2012-05-07): the above was updated to include a Java-based XMLTV parser example as another alternative to PHP on the backend.
Conclusion
This script provides a basic way of downloading TV data in Tribune Media Services (TMS) format. It can even provide a translation into XMLTV format (which is slightly different than TMS, but conveys all the same data); however, it won’t help much with the display of the data on the front-end. For that, I would suggest looking into one of the approved applications for actually viewing your XMLTV listings in the familiar grid/list styled EPG. While most of the software there is designed to run on the desktop, I would highlight XSLTV for web-based applications. There is not yet a mobile-friendly XMLTV application but stay tuned for my new jQuery plugin (not yet available), which should hopefully be compatible with jQuery Mobile.
Related articles
- Email Reader (dustycodes.wordpress.com)
- I feel the need…the need for JSON parsing correctness and speed! (whereswalden.com)
- Facebook’s Timeline is nothing but a LAZY and BLUNT marketing data parser (gubatron.com)
- Why is JSON so popular? Developers want out of the syntax business (mongolab.com)
- Facebook Graph API with Drupal Feeds (darrenmothersele.com)
- 36 New APIs: Cloud-Based Video Encoding, Fotomoto, RealGravity (programmableweb.com)
