def tokenGenerator(videosource): base64string = base64.encodestring( '%s:%s' % (Utils.getUserName(), Utils.getUserPassword())).replace( '\n', '') url = 'http://gui.saan.tv/DynamicTokenGenerator.aspx?Composite=rtsp://localhost/' + videosource + '|0s|0.5147328531052358' req = urllib2.Request(url) req.add_header( 'User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0' ) req.add_header('Host', 'gui.saan.tv') req.add_header( 'Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8') req.add_header('Accept-Language', 'en-GB,en;q=0.5') req.add_header('Accept-Charset', 'iso-8859-1, utf-8, utf-16, *;q=0.1') req.add_header('Accept-Encoding', 'gzip, deflate') req.add_header('Referer', 'http://gui.saan.tv/') req.add_header('Connection', 'Keep-Alive') req.add_header('Authorization', 'Basic %s' % base64string) try: handle = urllib2.urlopen(req) except IOError, e: Utils.log('IOError' + e)
def play_video(path): url = 'http://208.43.127.124/GUI_CS2?Composite=' + tokenGenerator( path ) + '%7crtsp://localhost/' + path + '%7c0s%7cSAAN_' + Utils.getUserName() play_item = xbmcgui.ListItem(path=url) # Pass the item to the Kodi player. xbmcplugin.setResolvedUrl(handle, True, listitem=play_item)