You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.9 KiB

11 years ago
11 years ago
11 years ago
11 years ago
  1. # coding: utf-8
  2. import re
  3. from ..utils import (
  4. compat_urllib_request,
  5. compat_urllib_parse
  6. )
  7. from .common import InfoExtractor
  8. class WeBSurgIE(InfoExtractor):
  9. IE_NAME = u'websurg.com'
  10. _VALID_URL = r'http://.*?\.websurg\.com/MEDIA/\?noheader=1&doi=(.*)'
  11. _TEST = {
  12. u'url': u'http://www.websurg.com/MEDIA/?noheader=1&doi=vd01en4012',
  13. u'file': u'vd01en4012.mp4',
  14. u'params': {
  15. u'skip_download': True,
  16. },
  17. u'skip': u'Requires login information',
  18. }
  19. _LOGIN_URL = 'http://www.websurg.com/inc/login/login_div.ajax.php?login=1'
  20. def _real_initialize(self):
  21. login_form = {
  22. 'username': self._downloader.params['username'],
  23. 'password': self._downloader.params['password'],
  24. 'Submit': 1
  25. }
  26. request = compat_urllib_request.Request(
  27. self._LOGIN_URL, compat_urllib_parse.urlencode(login_form))
  28. request.add_header(
  29. 'Content-Type', 'application/x-www-form-urlencoded;charset=utf-8')
  30. compat_urllib_request.urlopen(request).info()
  31. webpage = self._download_webpage(self._LOGIN_URL, '', 'Logging in')
  32. if webpage != 'OK':
  33. self._downloader.report_error(
  34. u'Unable to log in: bad username/password')
  35. def _real_extract(self, url):
  36. video_id = re.match(self._VALID_URL, url).group(1)
  37. webpage = self._download_webpage(url, video_id)
  38. url_info = re.search(r'streamer="(.*?)" src="(.*?)"', webpage)
  39. return {'id': video_id,
  40. 'title': self._og_search_title(webpage),
  41. 'description': self._og_search_description(webpage),
  42. 'ext' : 'mp4',
  43. 'url' : url_info.group(1) + '/' + url_info.group(2),
  44. 'thumbnail': self._og_search_thumbnail(webpage)
  45. }