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.8 KiB

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