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.

60 lines
1.9 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import base64
  4. from .common import InfoExtractor
  5. from ..compat import compat_urllib_request
  6. from ..utils import qualities
  7. class DumpertIE(InfoExtractor):
  8. _VALID_URL = r'https?://(?:www\.)?dumpert\.nl/mediabase/(?P<id>[0-9]+/[0-9a-zA-Z]+)'
  9. _TEST = {
  10. 'url': 'http://www.dumpert.nl/mediabase/6646981/951bc60f/',
  11. 'md5': '1b9318d7d5054e7dcb9dc7654f21d643',
  12. 'info_dict': {
  13. 'id': '6646981/951bc60f',
  14. 'ext': 'mp4',
  15. 'title': 'Ik heb nieuws voor je',
  16. 'description': 'Niet schrikken hoor',
  17. 'thumbnail': 're:^https?://.*\.jpg$',
  18. }
  19. }
  20. def _real_extract(self, url):
  21. video_id = self._match_id(url)
  22. req = compat_urllib_request.Request(url)
  23. req.add_header('Cookie', 'nsfw=1; cpc=10')
  24. webpage = self._download_webpage(req, video_id)
  25. files_base64 = self._search_regex(
  26. r'data-files="([^"]+)"', webpage, 'data files')
  27. files = self._parse_json(
  28. base64.b64decode(files_base64.encode('utf-8')).decode('utf-8'),
  29. video_id)
  30. quality = qualities(['flv', 'mobile', 'tablet', '720p'])
  31. formats = [{
  32. 'url': video_url,
  33. 'format_id': format_id,
  34. 'quality': quality(format_id),
  35. } for format_id, video_url in files.items() if format_id != 'still']
  36. self._sort_formats(formats)
  37. title = self._html_search_meta(
  38. 'title', webpage) or self._og_search_title(webpage)
  39. description = self._html_search_meta(
  40. 'description', webpage) or self._og_search_description(webpage)
  41. thumbnail = files.get('still') or self._og_search_thumbnail(webpage)
  42. return {
  43. 'id': video_id,
  44. 'title': title,
  45. 'description': description,
  46. 'thumbnail': thumbnail,
  47. 'formats': formats
  48. }