Advertisement
wandrake

Untitled

Jul 3rd, 2013
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. import utils, re
  2.  
  3. from urlmanaggio import *
  4.  
  5. class RaiTV:
  6.     urlazzo = 'http://www.rai.tv/dl/RaiTV/programmi/media/ContentItem-%s.html'
  7.  
  8.     def __init__(self, content_id, path='./video.mp4'):
  9.         self.content_id = content_id
  10.         self.path = path
  11.         self.getVideo()
  12.  
  13.     def getVideo(self):
  14.         html = utils.URL2html(self.urlazzo % self.content_id)
  15.         url1 = re.findall('<meta name="videourl" content="([^"]+)"/>', html)[0]
  16.         um1 = URLManaggio(url1)
  17.  
  18.         if um1.isVideo():
  19.             um1.save(self.path)
  20.         else:
  21.             file1 = um1.readAll()
  22.  
  23.             url2 = 'http%s' % (re.findall('HREF="(.*)"', file1)[0][3:])
  24.             file2 = URLManaggio(url2).readAll()
  25.  
  26.             url3 = re.findall('Ref2=(.*)\r', file2)[0]
  27.             URLManaggio(url3).save(self.path)
  28.  
  29. #RaiTV('df80db61-1750-47d9-ad73-ead09feb215b')
  30. #RaiTV('2ff84f96-793b-4edb-bb18-b64633dffbbf')
  31. RaiTV('0520971b-4d3a-4209-b69c-00a10b6a1b33')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement