Friday, December 28, 2012

Invalid cookies on Android & WeepeeTV

I'm trying to build an android application that logs in on the weepeetv website and does the parsing/screenscraping directly on android.

Unfortunately, the weepeetv site is setting cookies with an incorrect Expire date.

Android does not like this.

W/ResponseProcessCookies(20386): Invalid cookie header: "Set-Cookie: snip; expires=; path=/; 
isSecure=false". Unable to parse expires attribute:

I've been trying to use different http implementations: HttpClient versus HttpURLConnection but to no avail.  

Nothing works.

So the only solution I found is doing the parsing on Linux, running a webserver with the parsed XML file and providing this to the android application. (or compiling curl for android, but this is too much work for now :)

This works.

The next challenge is actually playing those streaming files. (hint: https)

Thursday, December 27, 2012

WeepeeTV and VLC

Started testdriving WeepeeTV this week, bought a subscription for a month (for now).
You can watch tv (SD quality / H264 encoded) using flash (cpu intensive) or HLS.

Unfortunately there's no API available.

But with some creative screenscraping and parsing a lot of fun stuff can be done. 
One example below is a VLC plugin which uses my own xml file (created by screenscraping) as a source.
Very easy way to switch channels without clicking too much or using a browser.

I will put my xml creating script on github, so you can use it too :-)

To use this lua script put it in the lua/sd directory and call it weepeetv.lua
Ofcourse you need to change the parse_url to your own server or local file.

--SD_Description=WeePee TV
 Authors: 42wim

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.

require "simplexml"

function descriptor()
    return { title="WeePee TV" }

function main()
local tree = simplexml.parse_url("http://192.168.x.x:8080/input.xml")
    for _, items in ipairs( tree.children ) do
        local url = vlc.strings.resolve_xml_special_chars( items.children_map['h264'][1].children[1] )
        local title = vlc.strings.resolve_xml_special_chars( items.children_map['title'][1].children[1] )
        local arturl = vlc.strings.resolve_xml_special_chars( items.children_map['thumb'][1].children[1] ) { path = url, title = title , arturl = arturl } )