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.

65 lines
1.9 KiB

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