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.

63 lines
1.9 KiB

  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. compat_urllib_parse,
  7. compat_urllib_request,
  8. )
  9. class VodlockerIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?vodlocker\.com/(?P<id>[0-9a-zA-Z]+)(?:\..*?)?'
  11. _TESTS = [{
  12. 'url': 'http://vodlocker.com/e8wvyzz4sl42',
  13. 'md5': 'ce0c2d18fa0735f1bd91b69b0e54aacf',
  14. 'info_dict': {
  15. 'id': 'e8wvyzz4sl42',
  16. 'ext': 'mp4',
  17. 'title': 'Germany vs Brazil',
  18. 'thumbnail': 're:http://.*\.jpg',
  19. },
  20. }]
  21. def _real_extract(self, url):
  22. mobj = re.match(self._VALID_URL, url)
  23. video_id = mobj.group('id')
  24. webpage = self._download_webpage(url, video_id)
  25. fields = dict(re.findall(r'''(?x)<input\s+
  26. type="hidden"\s+
  27. name="([^"]+)"\s+
  28. (?:id="[^"]+"\s+)?
  29. value="([^"]*)"
  30. ''', webpage))
  31. if fields['op'] == 'download1':
  32. self._sleep(3, video_id) # they do detect when requests happen too fast!
  33. post = compat_urllib_parse.urlencode(fields)
  34. req = compat_urllib_request.Request(url, post)
  35. req.add_header('Content-type', 'application/x-www-form-urlencoded')
  36. webpage = self._download_webpage(
  37. req, video_id, 'Downloading video page')
  38. title = self._search_regex(
  39. r'id="file_title".*?>\s*(.*?)\s*<span', webpage, 'title')
  40. thumbnail = self._search_regex(
  41. r'image:\s*"(http[^\"]+)",', webpage, 'thumbnail')
  42. url = self._search_regex(
  43. r'file:\s*"(http[^\"]+)",', webpage, 'file url')
  44. formats = [{
  45. 'format_id': 'sd',
  46. 'url': url,
  47. }]
  48. return {
  49. 'id': video_id,
  50. 'title': title,
  51. 'thumbnail': thumbnail,
  52. 'formats': formats,
  53. }