Advertisement
Guest User

stacked

a guest
Nov 21st, 2009
771
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.12 KB | None | 0 0
  1. #FreedoCast.com script for XBMC, by stacked (11/21/09)
  2. #Input stream name at keyboard prompt
  3.  
  4. import xbmc, xbmcgui, urllib2, urllib, re, string
  5. HEADER = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1'
  6.  
  7. searchStr = 'http://www.freedocast.com/'
  8. keyboard = xbmc.Keyboard(searchStr, "Enter stream name:")
  9. keyboard.doModal()
  10. if (keyboard.isConfirmed() == False):
  11.     dialog = xbmcgui.Dialog()
  12.     ok = dialog.ok('FreedoCast.com', 'Error: No stream found.')
  13.     xbmc.executebuiltin( "Container.Refresh" )
  14. searchstring = keyboard.getText()
  15. newStr = searchstring.replace(' ','%20')
  16. if len(newStr) == 0:
  17.     dialog = xbmcgui.Dialog()
  18.     ok = dialog.ok('FreedoCast.com', 'Error: No stream found.')
  19.     xbmc.executebuiltin( "Container.Refresh" )
  20. url=newStr
  21. name=url
  22. req = urllib2.Request(url)
  23. req.add_header('User-Agent', HEADER)
  24. content=urllib2.urlopen(req)
  25. data=content.read()
  26. content.close()
  27. freeid=re.compile('fid=\'(.+?)\';ftype').findall(data)[0]
  28. url='http://www.freedocast.com/forms/watchstream.aspx?sc='+freeid
  29. req = urllib2.Request(url)
  30. req.add_header('User-Agent', HEADER)
  31. req.add_header('Referer', 'http://www.freedocast.com')
  32. content=urllib2.urlopen(req)
  33. data=content.read()
  34. content.close()
  35. if data.find('rtmp') != -1:
  36.     tcUrl=re.compile('netConnectionUrl:\'(.+?)\'\r\n', re.DOTALL).findall(data)[0]
  37.     swfUrl=re.compile('src:\'(.+?)\'').findall(data)[0]
  38.     playPath=re.compile('url:\'(.+?)\'').findall(data)[0]
  39.     pageUrl='http://www.freedocast.com/forms/PopOut.aspx?sc='+freeid
  40.     thumb = xbmc.getInfoImage( "ListItem.Thumb" )
  41.     item = xbmcgui.ListItem(name, iconImage=thumb, thumbnailImage=thumb)
  42.     item.setInfo( type="Video", infoLabels={ "Title": name, "Director": 'FreedoCast.com', "Studio": 'FreedoCast.com' } )
  43.     item.setProperty("SWFPlayer", swfUrl)
  44.     item.setProperty("PlayPath", playPath)
  45.     item.setProperty("PageURL", pageUrl)
  46.     item.setProperty("IsLive", "true")
  47.     item.setProperty("tcUrl", tcUrl)
  48.     xbmc.Player(xbmc.PLAYER_CORE_DVDPLAYER).play(tcUrl, item)
  49. else:
  50.     dialog = xbmcgui.Dialog()
  51.     ok = dialog.ok('FreedoCast.com', 'Error: Not a live stream.')
  52.     xbmc.executebuiltin( "Container.Refresh" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement