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.

56 lines
1.7 KiB

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