Example #1
0
def fetch_stream_info(channel, bitrate, req_provider):
    (sort, stream_id, label, thumb) = live_tv_channels[channel]

    if bitrate <= 480: quality = 'iplayer_streaming_h264_flv_lo_live'
    elif bitrate == 800: quality = 'iplayer_streaming_h264_flv_live'
    elif bitrate >= 1500: quality = 'iplayer_streaming_h264_flv_high_live'

    # bbc news 24 uses different service names for the streams 
    if channel == "bbc_news24":
        if bitrate <= 480: quality = 'journalism_uk_stream_h264_flv_lo_live'
        elif bitrate == 800: quality = 'journalism_uk_stream_h264_flv_med_live'
        elif bitrate >= 1500: quality = 'journalism_uk_stream_h264_flv_high_live'

    if channel == "bbc_parliament" or channel == "bbc_alba":
        quality = 'iplayer_streaming_vp6_flv_lo_live'

    surl = 'http://www.bbc.co.uk/mediaselector/4/mtis/stream/%s/%s/%s' % (stream_id, quality, req_provider)
    logging.info("getting media information from %s" % surl)
    root = parseXML(surl)
    mbitrate = 0
    url = ""
    media = root.getElementsByTagName( "media" )[0]

    conn  = media.getElementsByTagName( "connection" )[0]

    # rtmp streams
    identifier  = conn.attributes['identifier'].nodeValue
    server      = conn.attributes['server'].nodeValue
    auth        = conn.attributes['authString'].nodeValue
    supplier    = conn.attributes['supplier'].nodeValue

    # not always listed for some reason
    try: 
        application = conn.attributes['application'].nodeValue
    except:
        application = 'live'

    params = dict(protocol = get_protocol(), port = get_port(), server = server, auth = auth, ident = identifier, app = application)

    if supplier == "akamai" or supplier == "limelight":
        if supplier == "akamai":
            url = "%(protocol)s://%(server)s:%(port)s/%(app)s/?%(auth)s playpath=%(ident)s?%(auth)s" % params
        if supplier == "limelight":
            url = "%(protocol)s://%(server)s:%(port)s/ app=%(app)s?%(auth)s tcurl=%(protocol)s://%(server)s:%(port)s/%(app)s?%(auth)s playpath=%(ident)s" % params
        url += " swfurl=http://www.bbc.co.uk/emp/10player.swf swfvfy=1 live=1"

    return (url)
def fetch_stream_info(stream_id, req_bitrate, req_provider):



    if   req_bitrate <= 480: quality = 1
    elif req_bitrate == 800: quality = 2
    elif req_bitrate >= 1500: quality = 3

    if   quality == 1: quality_attr = 'pc_stream_audio_video_webcast_uk_v_lm_p004'
    elif quality == 2: quality_attr = 'pc_stream_audio_video_webcast_uk_v_lm_p005'
    elif quality == 3: quality_attr = 'pc_stream_audio_video_webcast_uk_v_lm_p006'

    if stream_id == "bbc_three" or stream_id == "bbc_two_england" or stream_id == "bbc_one_london":
	# if the pids are the same, its one of the bbc channels rather than just a regular net stream. They are different for some reason
	method=2
    else: method=1

    if method == 2:
	    if   quality == 1: quality_attr = 'pc_stream_audio_video_simulcast_uk_v_lm_p004'
	    elif quality == 2: quality_attr = 'pc_stream_audio_video_simulcast_uk_v_lm_p005'
	    elif quality == 3: quality_attr = 'pc_stream_audio_video_simulcast_uk_v_lm_p006'


    # if user chooses a stream type that doesn't exist for live, switch to "auto" mode
    if req_provider != 'akamai' and req_provider != 'limelight':
        provider = ''

    # bbc one seem to switch between "akamai_hd" and "akamai"
    #if ( channel == "bbc_one_london" or channel == "bbc_two_england" ) and req_provider == "akamai":
    #    req_provider = "akamai_hd"

    surl = 'http://www.bbc.co.uk/mediaselector/4/mtis/stream/%s/%s/%s' % (stream_id, quality_attr, provider)
    logging.info("getting media information from %s" % surl)
    root = parseXML(surl)
    mbitrate = 0
    url = ""
    if root.getElementsByTagName( "error" ) and root.getElementsByTagName( "error" )[0].attributes["id"].nodeValue == 'notavailable': return ""
    media = root.getElementsByTagName( "media" )[0]

    conn  = media.getElementsByTagName( "connection" )[0]

    # rtmp streams
    identifier  = conn.attributes['identifier'].nodeValue
    server      = conn.attributes['server'].nodeValue
    auth        = conn.attributes['authString'].nodeValue
    supplier    = conn.attributes['supplier'].nodeValue

    # not always listed for some reason
    try:
        application = conn.attributes['application'].nodeValue
    except:
        application = 'live'

    params = dict(protocol = get_protocol(), port = get_port(), server = server, auth = auth, ident = identifier, app = application)

    if supplier == "akamai" or supplier == "limelight":
        if supplier == "akamai":
            url = "%(protocol)s://%(server)s:%(port)s/%(app)s/?%(auth)s playpath=%(ident)s?%(auth)s" % params
        if supplier == "limelight":
            url = "%(protocol)s://%(server)s:%(port)s/ app=%(app)s?%(auth)s tcurl=%(protocol)s://%(server)s:%(port)s/%(app)s?%(auth)s playpath=%(ident)s" % params
        url += " swfurl=http://www.bbc.co.uk/emp/10player.swf swfvfy=1 live=1"
    elif supplier == "akamai_hd":
        url = conn.attributes['href'].nodeValue

    return (url)
Example #3
0
def fetch_stream_info(channel, req_bitrate, req_provider):
    (sort, stream_id, label, thumb) = live_tv_channels[channel]

    provider = req_provider;

    if   req_bitrate <= 480: quality = 1
    elif req_bitrate == 800: quality = 2
    elif req_bitrate >= 1500: quality = 3

    if   quality == 1: quality_attr = 'iplayer_streaming_h264_flv_lo_live'
    elif quality == 2: quality_attr = 'iplayer_streaming_h264_flv_live'
    elif quality == 3: quality_attr = 'iplayer_streaming_h264_flv_high_live'

    # bbc news 24 uses different service names for the streams 
    if channel == 'bbc_news24':
        if   quality == 1: quality_attr = 'journalism_uk_stream_h264_flv_lo_live'
        elif quality == 2: quality_attr = 'journalism_uk_stream_h264_flv_med_live'
        elif quality == 3: quality_attr = 'journalism_uk_stream_h264_flv_high_live'
        
    if stream_id == 'bbc_three' or stream_id == 'bbc_four':
        if   quality == 1: quality_attr = 'pc_stream_audio_video_simulcast_uk_v_lm_p004'
        elif quality == 2: quality_attr = 'pc_stream_audio_video_simulcast_uk_v_lm_p005'
        elif quality == 3: quality_attr = 'pc_stream_audio_video_simulcast_uk_v_lm_p006'

    if channel == 'bbc_parliament' or channel == 'bbc_alba':
        quality_attr = ''
        provider = ''
        
    if channel == 'bbc_redbutton':
        provider = ''

    # if user chooses a stream type that doesn't exist for live, switch to "auto" mode
    if req_provider != 'akamai' and req_provider != 'limelight':
        provider = ''

    # bbc one seem to switch between "akamai_hd" and "akamai"
    #if ( channel == "bbc_one_london" or channel == "bbc_two_england" ) and req_provider == "akamai":
    #    req_provider = "akamai_hd"

    surl = 'http://www.bbc.co.uk/mediaselector/4/mtis/stream/%s/%s/%s' % (stream_id, quality_attr, provider)
    logging.info("getting media information from %s" % surl)
    root = parseXML(surl)
    mbitrate = 0
    url = ""
    media = root.getElementsByTagName( "media" )[0]

    conn  = media.getElementsByTagName( "connection" )[0]

    # rtmp streams
    identifier  = conn.attributes['identifier'].nodeValue
    server      = conn.attributes['server'].nodeValue
    auth        = conn.attributes['authString'].nodeValue
    supplier    = conn.attributes['supplier'].nodeValue

    # not always listed for some reason
    try:
        application = conn.attributes['application'].nodeValue
    except:
        application = 'live'

    params = dict(protocol = get_protocol(), port = get_port(), server = server, auth = auth, ident = identifier, app = application)

    if supplier == "akamai" or supplier == "limelight":
        if supplier == "akamai":
            url = "%(protocol)s://%(server)s:%(port)s/%(app)s/?%(auth)s playpath=%(ident)s?%(auth)s" % params
        if supplier == "limelight":
            url = "%(protocol)s://%(server)s:%(port)s/ app=%(app)s?%(auth)s tcurl=%(protocol)s://%(server)s:%(port)s/%(app)s?%(auth)s playpath=%(ident)s" % params
        url += " swfurl=http://www.bbc.co.uk/emp/10player.swf swfvfy=1 live=1"
    elif supplier == "akamai_hd":
        url = conn.attributes['href'].nodeValue

    return (url)