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.

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