logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

dumpert.py (2701B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. qualities,
  7. )
  8. class DumpertIE(InfoExtractor):
  9. _VALID_URL = r'(?P<protocol>https?)://(?:(?:www|legacy)\.)?dumpert\.nl/(?:mediabase|embed|item)/(?P<id>[0-9]+[/_][0-9a-zA-Z]+)'
  10. _TESTS = [{
  11. 'url': 'https://www.dumpert.nl/item/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': r're:^https?://.*\.jpg$',
  19. }
  20. }, {
  21. 'url': 'https://www.dumpert.nl/embed/6675421_dc440fe7',
  22. 'only_matching': True,
  23. }, {
  24. 'url': 'http://legacy.dumpert.nl/mediabase/6646981/951bc60f',
  25. 'only_matching': True,
  26. }, {
  27. 'url': 'http://legacy.dumpert.nl/embed/6675421/dc440fe7',
  28. 'only_matching': True,
  29. }]
  30. def _real_extract(self, url):
  31. video_id = self._match_id(url).replace('_', '/')
  32. item = self._download_json(
  33. 'http://api-live.dumpert.nl/mobile_api/json/info/' + video_id.replace('/', '_'),
  34. video_id)['items'][0]
  35. title = item['title']
  36. media = next(m for m in item['media'] if m.get('mediatype') == 'VIDEO')
  37. quality = qualities(['flv', 'mobile', 'tablet', '720p'])
  38. formats = []
  39. for variant in media.get('variants', []):
  40. uri = variant.get('uri')
  41. if not uri:
  42. continue
  43. version = variant.get('version')
  44. formats.append({
  45. 'url': uri,
  46. 'format_id': version,
  47. 'quality': quality(version),
  48. })
  49. self._sort_formats(formats)
  50. thumbnails = []
  51. stills = item.get('stills') or {}
  52. for t in ('thumb', 'still'):
  53. for s in ('', '-medium', '-large'):
  54. still_id = t + s
  55. still_url = stills.get(still_id)
  56. if not still_url:
  57. continue
  58. thumbnails.append({
  59. 'id': still_id,
  60. 'url': still_url,
  61. })
  62. stats = item.get('stats') or {}
  63. return {
  64. 'id': video_id,
  65. 'title': title,
  66. 'description': item.get('description'),
  67. 'thumbnails': thumbnails,
  68. 'formats': formats,
  69. 'duration': int_or_none(media.get('duration')),
  70. 'like_count': int_or_none(stats.get('kudos_total')),
  71. 'view_count': int_or_none(stats.get('views_total')),
  72. }