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.

67 lines
2.2 KiB

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