Want more features on Pastebin? Sign Up, it's FREE!
Guest

videoweed.py get_media_url

By: a guest on Aug 20th, 2011  |  syntax: Python  |  size: 1.35 KB  |  views: 269  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.     def get_media_url(self, web_url):
  2.         #grab stream address
  3.         try:
  4.             html = self.net.http_GET(web_url).content
  5.         except urllib2.URLError, e:
  6.             common.addon.log_error('videoweed: got http error %d fetching %s' %
  7.                                     (e.code, web_url))
  8.             return False
  9.        
  10.         r = re.search('flashvars.domain="(.+?)";.*flashvars.file="([a-zA-Z0-9]+)";.*flashvars.filekey="(.+?)";.+?flashvars', html, re.DOTALL)
  11.         if r:
  12.             domain = r.group(1)
  13.             fileid = r.group(2)
  14.             filekey = r.group(3)
  15.             api_call = domain + '/api/player.api.php?user=undefined&codes=1&file=' + fileid + '&pass=undefined&key=' + filekey
  16.         else:
  17.             common.addon.log_error('videoweed: api url not found')
  18.             return False
  19.  
  20.         try:
  21.             apihtml = self.net.http_GET(api_call).content
  22.         except urllib2.URLERROR, e:
  23.             common.addon.log_error('videoweed: failed to call the video API got http error %d fetching %s' %
  24.                                    (e.code, api_call))
  25.             return False
  26.  
  27.         rapi = re.search('url=(.+?)&title=',apihtml)
  28.         if rapi:
  29.             stream_url = rapi.group(1)
  30.         else:
  31.             common.addon.log_error('videoweed: stream url not found')
  32.  
  33.        
  34.         return stream_url
clone this paste RAW Paste Data