Ustream mp4

  • /*
     * @title Ustream mp4
     * @description flash-free Ustream
     * @include http://www.ustream.tv/*
     * @license MIT License http://opensource.org/licenses/MIT
     * @javascript_url
     */
    
    // web <video> player
    // http://txton.net/hoehoe/sample/ustplayer02/
    // http://txton.net/hoehoe/2010/100810165217.html
    
    // alt. livestreamer
    // http://docs.livestreamer.io/
    // https://github.com/chrippa/livestreamer
    // https://github.com/chrippa/livestreamer/wiki/Alternative-interfaces
    
    // c.f.
    // http://developer.ustream.tv/data_api/docs
    // http://ustream.github.io/api-docs/
    
    // e.g.
    // http://www.ustream.tv/nasahdtv
    // http://www.ustream.tv/channel/live-iss-stream
    (function () {
        // channel-id
        // <meta name="ustream:channel_id" content="9408562">
        // TODO use API w/ ajax c.f. http://let.hatelabo.jp/noromanba/let/gYC-x-X5mL3cAA
        //      header unchanged when pjax, so differ <head> and <body> WTF
        var id = (document.head.querySelector('meta[name="ustream:channel_id"][content]') || {}).content;
        if (!id) return;
    
        // HTML5 HLS endpoint (http only)
        // http://iphone-streaming.ustream.tv/uhls/CHANNEL_ID/streams/live/iphone/playlist.m3u8
        // http://iphone-streaming.ustream.tv/ustreamVideo/CHANNEL_ID/streams/live/playlist.m3u8
        // TODO 480p+, needs spoof UA to iPad/Safari
        var HLS_URL = [
            'http://iphone-streaming.ustream.tv/uhls/',
            id,
            '/streams/live/playlist.m3u8'
        ].join('');
    
        // TODO open in same tab/window, but couldn't X-domain GET
        //      not provided CORS: 'Access-Control-Allow-Origin'
        // cleanup c.f. http://jsperf.com/innerhtml-vs-removechild/157
        /*/
        var body = document.body;
        while (body.firstChild) { // TBD range
            body.removeChild(body.firstChild);
        }
    
        // Safari/iPad only
        var video = document.createElement('video');
        video.src = HLS_URL;
        //video.type = 'video/mp4'
        //video.controls = true;
        document.body.appendChild(video);
    
        /*/
        // TBD window.open()
        // open w/ mplayer, ffplay, avplay, cvlc, vlc et al.
        window.prompt('streaming URL', HLS_URL);
        //*/
    })();
    
    // # DBG
    //
    // ## player info API
    //
    // http://api.ustream.tv/html/channel/CHANNEL_ID/getInfo
    // http://api.ustream.tv/html/user/USER_ID/getInfo
    //
    // e.g.
    // http://api.ustream.tv/html/channel/live-iss-stream/getInfo
    // http://api.ustream.tv/html/user/NASAtelevision/getInfo
    //
    // ## HLS API
    //
    // HTML5 HLS endpoint (http only)
    // http://iphone-streaming.ustream.tv/uhls/CHANNEL_ID/streams/live/iphone/playlist.m3u8
    // http://iphone-streaming.ustream.tv/ustreamVideo/CHANNEL_ID/streams/live/playlist.m3u8
    //
    // e.g.
    // http://www.ustream.tv/channel/live-iss-stream
    // http://iphone-streaming.ustream.tv/uhls/9408562/streams/live/playlist.m3u8
    //
    // ## request
    //
    // ### HEAD
    //
    //     $ HEAD "http://iphone-streaming.ustream.tv/uhls/9408562/streams/live/playlist.m3u8"
    //     200 OK
    //     Connection: close
    //     Date: Sat, 20 Jun 2015 16:05:57 GMT
    //     Server: Jetty(7.x.y-SNAPSHOT)
    //     Content-Type: application/vnd.apple.mpegurl
    //     Client-Date: Sat, 20 Jun 2015 16:05:57 GMT
    //     Client-Peer: 199.66.239.195:80
    //     Client-Response-Num: 1
    //     Set-Cookie: uhls.9408562=oldurl-9cabc150074b9f6d82847995553273e98f5ba294; path=/; domain=sjc-uhls-proxy103.ustream.tv; Max-Age=900; HttpOnly
    //
    // ### GET
    //
    //     $ GET "http://iphone-streaming.ustream.tv/uhls/9408562/streams/live/playlist.m3u8"
    //     #EXTM3U
    //     #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=719615,CODECS="avc1.77.21, mp4a.40.2",RESOLUTION=426x284
    //     http://sjc-uhls-proxy103.ustream.tv/watch/playlist.m3u8?appType=103&appVersion=3&conn=wifi&cid=9408562&stream=viewer_240p&connectionId=oldurl-9cabc150074b9f6d82847995553273e98f5ba294&group=iphone
    //
    // ----
    //
    // ### Hi-Resolution
    // spoof of UA to iPad/Safari
    //
    //     $ GET "http://sjc-uhls-proxy103.ustream.tv/watch/playlist.m3u8?cid=17074538&appType=11&appVersion=2&locks=97d170e1550eee4afc0af065b78cda302a97674c&geo=JP&geocity=&userId=&connectionId=sjc-flot-live03_1894980111&ts=1434828433&ip=XXX.XXX.XX.XX&cdn=uhs_akamai&sgn=5bada09321398f9f40485e8de2681490b2d43a98"
    //     #EXTM3U
    //     #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1080779,CODECS="avc1.77.30, mp4a.40.2",RESOLUTION=640x360
    //     http://sjc-uhls-proxy103.ustream.tv/watch/playlist.m3u8?appType=11&appVersion=2&conn=wifi&cdn=uhs_akamai&locks=97d170e1550eee4afc0af065b78cda302a97674c&cid=17074538&stream=viewer_360p&connectionId=sjc-flot-live03_1894980111&group=iphone
    //     #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1420901,CODECS="avc1.77.31, mp4a.40.2",RESOLUTION=854x480
    //     http://sjc-uhls-proxy103.ustream.tv/watch/playlist.m3u8?appType=11&appVersion=2&conn=wifi&cdn=uhs_akamai&locks=97d170e1550eee4afc0af065b78cda302a97674c&cid=17074538&stream=viewer_480p&connectionId=sjc-flot-live03_1894980111&group=iphone
    //     #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=744729,CODECS="avc1.77.21, mp4a.40.2",RESOLUTION=426x240
    //     http://sjc-uhls-proxy103.ustream.tv/watch/playlist.m3u8?appType=11&appVersion=2&conn=wifi&cdn=uhs_akamai&locks=97d170e1550eee4afc0af065b78cda302a97674c&cid=17074538&stream=viewer_240p&connectionId=sjc-flot-live03_1894980111&group=iphone
    //
    
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2015/06/21 07:17:01 - 2015-06-21
  2. 2015/06/21 05:17:18 - 2015-06-21
  3. 2015/06/20 16:19:24 - 2015-06-20