HOW-TO play UStream livestreams
#1
To all addon developers that need ustream. This is how to get the stream url:

Taken from a SportsDevil config file:
Code:
########################################################
# Ustream.tv - Videos
########################################################
item_infos="(http://www.ustream.tv/channel-popup/([^"]+))"
item_order=tmpUrl|channel

item_info_name=rtmp
item_info_from=channel
item_info_convert=getInfo('http://cgw.ustream.tv/Viewer/getStream/1/%s.amf','.*(rtmp://ustream.+?)\x00.*')
item_info_build=%s

item_info_name=stream
item_info_from=channel
item_info_convert=getInfo('http://cgw.ustream.tv/Viewer/getStream/1/%s.amf','.*streamName\W\W\W(.+?)[/]*\x00.*')
item_info_build=%s

item_info_name=swf
item_info_from=tmpUrl
item_info_convert=getInfo('%s','.*movie:\s*"([^"]+)".*')
item_info_build=%s

item_info_name=url
item_info_from=rtmp + stream + ' swfUrl=' + swf + ' swfVfy=1 live=true pageUrl=' + tmpUrl
item_info_build=%s

item_info_name=title
item_info_from=url
item_info_build=Ustream - %s

item_info_name=type
item_info_build=direct.video  

item_url_build=%s

Take care that the 'stream' part of the url doesn't end with a slash.

Have fun! Smile
Reply
#2
So what are or where do I get the values for "item_order=tmpUrl|channel"??

I'm trying to see if I can get the TWiT Live stream, http://www.ustream.tv/leolaporte
Reply
#3
divingmule Wrote:So what are or where do I get the values for "item_order=tmpUrl|channel
"??

I'm trying to see if I can get the TWiT Live stream, http://www.ustream.tv/leolaporte

Come on, you're plugin developer yourself. This syntax is very simple.

You can see the corresponding regex right above. The outer pair of brackets is for tmpUrl, the inner is for channel. That's the regular definition of regular expressions.

In your case the regex would be like:
item_infos="(http://www.ustream.tv/([^"]+))"
Reply
#4
MaxMustermann Wrote:To all addon developers that need ustream. This is how to get the stream url:
nice one Max!

i'll have to take a look and make a urlresolver plugin Wink
Reply
#5
MaxMustermann Wrote:Come on, you're plugin developer yourself. This syntax is very simple.

Yeah, I need to learn more about regular expressions. Thanks for the tips.

I had to do things a little different to get the TWiT url. The proper swfUrl wasn't in the .amf file and I had to change the regex a little for the rtmp url.

Others may find this useful -
Code:
import urllib2,urllib,re

def getSwf():
    url = 'http://www.ustream.tv/flash/viewer.swf'
    req = urllib2.Request(url)
    response = urllib2.urlopen(req)
    swfUrl = response.geturl()
    return swfUrl


url = 'http://cgw.ustream.tv/Viewer/getStream/1/1524.amf'
headers = {'User-agent' : 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'}
data = None
req = urllib2.Request(url,data,headers)
response = urllib2.urlopen(req)
link=response.read()
response.close()
match = re.compile('.*(rtmp://.+?)\x00.*').findall(link)
rtmp = match[0]
sName = re.compile('.*streamName\W\W\W(.+?)[/]*\x00.*').findall(link)
playpath = ' playpath='+sName[0]
swf = ' swfUrl='+getSwf()
pageUrl = ' pageUrl=http://live.twit.tv'
url = rtmp + playpath + swf + pageUrl + ' swfVfy=1 live=true'
print url

Thanks again for sharing your code.
Reply
#6
Hi, I know this is an old thread, but has anyone built this url resolver?
Reply

Logout Mark Read Team Forum Stats Members Help
HOW-TO play UStream livestreams1