View Single Post
  #2  
Old 06-17-2009, 03:24 AM
Stream Recorder
 
Posts: n/a
Default

Re: Flazr - open source RTMP stream saver


Script for downloading videos from Yahoo ! Music with flazr
This is an example of how you can easily write a script to request an HTML page (or XML data in this case), parse the contents and extract the values needed to invoke the main RTMP client / download routine

Code:
import com.flazr.*

def videoId = "201620741"

def url = "http://video.music.yahoo.com/ver/268.0/process/getPlaylistFOP.php?node_id=v" \
        + videoId + "&tech=flash&bitrate=5000&eventid=1301797";             

def xml = Utils.getOverHttp(url)

println xml

def data = new XmlSlurper().parseText(xml)
def stream = data.'SEQUENCE-ITEM'[1].STREAM

def tcUrl = stream.@APP.text()
def host = stream.@SERVER.text()
def queryString = stream.@QUERYSTRING.text()
def path = stream.@PATH.text().substring(1)

def app = tcUrl.substring(tcUrl.lastIndexOf('/') + 1)
def playParam = path.substring(0, path.lastIndexOf('.')) + '?' + queryString

println 'queryString: ' + queryString + '\n'
println 'path: ' + path + '\n'
println 'playParam: ' + playParam + '\n'
println 'app: ' + app + '\n'

def session = new RtmpSession(host, 1935, app, playParam, 'test.flv')

RtmpClient.connect session
Reply With Quote