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.

64 lines
2.1 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|embed)/(?P<id>[0-9]+/[0-9a-zA-Z]+)'
  9. _TESTS = [{
  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. 'url': 'http://www.dumpert.nl/embed/6675421/dc440fe7/',
  21. 'only_matching': True,
  22. }]
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. url = 'https://www.dumpert.nl/mediabase/' + video_id
  26. req = compat_urllib_request.Request(url)
  27. req.add_header('Cookie', 'nsfw=1; cpc=10')
  28. webpage = self._download_webpage(req, video_id)
  29. files_base64 = self._search_regex(
  30. r'data-files="([^"]+)"', webpage, 'data files')
  31. files = self._parse_json(
  32. base64.b64decode(files_base64.encode('utf-8')).decode('utf-8'),
  33. video_id)
  34. quality = qualities(['flv', 'mobile', 'tablet', '720p'])
  35. formats = [{
  36. 'url': video_url,
  37. 'format_id': format_id,
  38. 'quality': quality(format_id),
  39. } for format_id, video_url in files.items() if format_id != 'still']
  40. self._sort_formats(formats)
  41. title = self._html_search_meta(
  42. 'title', webpage) or self._og_search_title(webpage)
  43. description = self._html_search_meta(
  44. 'description', webpage) or self._og_search_description(webpage)
  45. thumbnail = files.get('still') or self._og_search_thumbnail(webpage)
  46. return {
  47. 'id': video_id,
  48. 'title': title,
  49. 'description': description,
  50. 'thumbnail': thumbnail,
  51. 'formats': formats
  52. }