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 ..compat 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. video_id = self._match_id(url)
  23. webpage = self._download_webpage(url, video_id)
  24. fields = dict(re.findall(r'''(?x)<input\s+
  25. type="hidden"\s+
  26. name="([^"]+)"\s+
  27. (?:id="[^"]+"\s+)?
  28. value="([^"]*)"
  29. ''', webpage))
  30. if fields['op'] == 'download1':
  31. self._sleep(3, video_id) # they do detect when requests happen too fast!
  32. post = compat_urllib_parse.urlencode(fields)
  33. req = compat_urllib_request.Request(url, post)
  34. req.add_header('Content-type', 'application/x-www-form-urlencoded')
  35. webpage = self._download_webpage(
  36. req, video_id, 'Downloading video page')
  37. title = self._search_regex(
  38. r'id="file_title".*?>\s*(.*?)\s*<(?:br|span)', webpage, 'title')
  39. thumbnail = self._search_regex(
  40. r'image:\s*"(http[^\"]+)",', webpage, 'thumbnail')
  41. url = self._search_regex(
  42. r'file:\s*"(http[^\"]+)",', webpage, 'file url')
  43. formats = [{
  44. 'format_id': 'sd',
  45. 'url': url,
  46. }]
  47. return {
  48. 'id': video_id,
  49. 'title': title,
  50. 'thumbnail': thumbnail,
  51. 'formats': formats,
  52. }