Mythtv's xmltv grabber for Malaysia channelsDecember 30, 2008 at 11:08 PM | categories: python, boleh, linux | View Comments
Ever since I got mythtv up and running months ago, I have always wanted to use the Electronic Program Guide (EPG) feature. Unfortunately, getting tv schedules in a format understandable by mythtv (i.e. xmltv) is not so easy.
From a bit of googling, I found 2 (non-)solutions. The first one involves using tvxb through wine to grab tv schedules from Astro through screenscraping. Apparently, it doesn't work anymore, as the tvxb site is showing the following message:
All Astro satellite channels (No longer works - needs updating. 2008/10/12)
The other solution is a perl script written by Shahada Abubakar that also screenscrapes Astro listing. Like the first one, this solution has also ceased to be working, due to the flaky nature of screenscraping.
Of course, the googling and testing were just unnecessary foreplay. I was set at the beginning to come up with my own solution anyway. With the help of wonderful python libraries such as BeautifulSoup and lxml, I wrote a xmltv grabber that:
can screenscrape either Astro or The Star listings for channels rtm1, rtm2, tv3, ntv7, 8tv, and tv9
is functioning as of 2008-12-31 (UPDATE: broken as of 2013-01-27, ugh)
Here's the script: grabmy.py
To get it to work, install the requirements first:
easy_install BeautifulSoup lxml httplib2 python_dateutil
Then, run the script to generate a xmltv file:
python grabmy.py -f my.xml
Feed mythbackend with the file:
mythfilldatabase --file 1 my.xml
And finally, here's the EPG in its full glory if you channel-flip at 2am: