Pages

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
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 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" }
end

function main()
local tree = simplexml.parse_url("http://192.168.x.x:8080/input.xml")
    for _, items in ipairs( tree.children ) do
        simplexml.add_name_maps(items)
        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] )
        vlc.sd.add_item( { path = url, title = title , arturl = arturl } ) 
    end
end


7 comments:

  1. So how do you get the SSL certificate installed in VLC?

    ReplyDelete
  2. You don't need to install a SSL certificate, weepee.tv isn't using a self signed one, there shouldn't be an issue. Be sure to use the latest VLC (2.0.5)

    Check out my other post (http://blog.42.be/2013/01/weepeetv-and-vlc-2.html) about weepeetv and vlc, there's a link to the script generating the XML and more information about how to use it.

    ReplyDelete
  3. Found the problem: http://trac.videolan.org/vlc/ticket/7724 because I'm on a Mac :-)
    GnuTLS doesn't support OS X keychain for getting the certificates it seems.

    I got the cert from https://www.globalsign.com/support/root-certificate/root-globalsign.php and put it in ~/Library/Preferences/org.videolan.vlc/ssl/certs/ca-certificates.crt and now I'm in business :)

    ReplyDelete
  4. Hi 42wim,

    with your script I hope to be able to watch weepeetv on my BSD. however i'm also suffering some TLS issues. I know it is not related to your code, but i haven't found any solution - or even a cause of the problem for that matter.

    Perhaps you encountered something similar somewhere during testing or stumbled upon similar problems?

    VLC isn't able to 'read' my CA chain:

    [0x28873f10] gnutls tls client debug: GnuTLS v2.12.18 initialized
    [0x28873f10] gnutls tls client debug: browsing x509 credentials in /home/filip/.local/share/vlc/ssl/certs...
    [0x28873f10] gnutls tls client debug: loading x509 credentials from globalsign-root-bundle-2011.crt...
    [0x28873f10] gnutls tls client warning: cannot read x509 credentials: Bad file descriptor

    permissions are fine...

    i know the CA's are fine too for the cert of weepeetv:

    [filip@gnix ~]$ cat wildcardcert.my-stream.eu.cer | openssl verify -CAfile .local/share/vlc/ssl/certs/globalsign-root-bundle-2011.crt -purpose sslserver
    stdin: OK

    Even while using gnutls-cli it is accepted:

    [filip@gnix ~]$ gnutls-cli -s weepeetv.my-stream.eu --x509cafile .local/share/vlc/ssl/certs/globalsign-root-bundle-2011.crt
    Processed 2 CA certificate(s).
    Resolving 'weepeetv.my-stream.eu'...
    Connecting to '37.143.7.7:443'...

    - Simple Client Mode:

    *** Starting TLS handshake
    ...
    - Certificate[0] info:
    - subject `OU=Domain Control Validated,CN=*.my-stream.eu', issuer `C=BE,O=GlobalSign nv-sa,CN=GlobalSign Domain Validation CA - G2', RSA key 2048 bits, signed using RSA-SHA1, activated `2012-12-12 10:25:53 UTC', expires `2015-12-13 10:25:53 UTC', SHA-1 fingerprint `70286185fdf0191f72734ea7b8beb920a0927888'
    - Certificate[1] info:
    - subject `C=BE,O=GlobalSign nv-sa,CN=GlobalSign Domain Validation CA - G2', issuer `C=BE,O=GlobalSign nv-sa,OU=Root CA,CN=GlobalSign Root CA', RSA key 2048 bits, signed using RSA-SHA1, activated `2011-04-13 10:00:00 UTC', expires `2022-04-13 10:00:00 UTC', SHA-1 fingerprint `2a3cf4bddc74ccaa480558f9d8d1d2a084f34b31'
    - The hostname in the certificate matches 'weepeetv.my-stream.eu'.
    - Peer's certificate is trusted
    ...


    So everything seems fine, except that gnutls inside vlc is unable to read the CA chain.

    Do you have an idea? Or did you encounter something similar?

    filip

    ReplyDelete
  5. Hi Filip,

    No idea, but you can use stunnel to fix this.
    Create stunnel.conf containing this:

    client = yes
    [proxy]
    accept = 127.0.0.1:1234
    # Replace SERVER with the address of the server setup previously
    connect = weepeetv.my-stream.eu:443

    run stunnel stunnel.conf
    adapt the xml file to change https://weepeetv.my-stream.eu to http://localhost:1234

    ReplyDelete
  6. Hey Wim
    I tried to use stunnel so I could play the streams using xbmc, but stunnel fails to start. It says that the server needs a certificate. Maybe you can help me?

    Nick

    ReplyDelete
  7. Hi Nick, shouldn't be an issue, if it's on a mac however I can't help you

    ReplyDelete