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.

63 lines
2.2 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. js_to_json,
  6. unescapeHTML
  7. )
  8. class DVTVIE(InfoExtractor):
  9. IE_NAME = 'dvtv'
  10. IE_DESC = 'http://video.aktualne.cz/dvtv/'
  11. _VALID_URL = r'http://video\.aktualne\.cz/dvtv/(?P<id>[a-z0-9-]+/r~[0-9a-f]{32})/?'
  12. _TESTS = [{
  13. 'url': 'http://video.aktualne.cz/dvtv/vondra-o-ceskem-stoleti-pri-pohledu-na-havla-mi-bylo-trapne/r~e5efe9ca855511e4833a0025900fea04/',
  14. 'md5': '75800f964fa0f82939a2914563301f72',
  15. 'info_dict': {
  16. 'id': 'e5efe9ca855511e4833a0025900fea04',
  17. 'ext': 'webm',
  18. 'title': 'Vondra o Českém století: Při pohledu na Havla mi bylo trapně'
  19. }
  20. }, {
  21. 'url': 'http://video.aktualne.cz/dvtv/stropnicky-policie-vrbetice-preventivne-nekontrolovala/r~82ed4322849211e4a10c0025900fea04/',
  22. 'md5': '6388f1941b48537dbd28791f712af8bf',
  23. 'info_dict': {
  24. 'id': '82ed4322849211e4a10c0025900fea04',
  25. 'ext': 'mp4',
  26. 'title': 'Stropnický: Policie Vrbětice preventivně nekontrolovala'
  27. }
  28. }]
  29. def _real_extract(self, url):
  30. video_id = self._match_id(url)
  31. webpage = self._download_webpage(url, video_id)
  32. code = self._search_regex(
  33. r'(?s)embedData[0-9a-f]{32}\[\'asset\'\] = (\{.+?\});',
  34. webpage, 'video JSON')
  35. payload = self._parse_json(code, video_id, transform_source=js_to_json)
  36. formats = []
  37. for source in payload['sources']:
  38. ext = source['type'][6:]
  39. formats.append({
  40. 'url': source['file'],
  41. 'ext': ext,
  42. 'format': '%s %s' % (ext, source['label']),
  43. 'format_id': '%s-%s' % (ext, source['label']),
  44. 'height': int(source['label'].rstrip('p')),
  45. 'fps': 25,
  46. })
  47. self._sort_formats(formats)
  48. return {
  49. 'id': video_id[-32:],
  50. 'display_id': video_id[:-35],
  51. 'title': unescapeHTML(payload['title']),
  52. 'thumbnail': 'http:%s' % payload['image'],
  53. 'formats': formats
  54. }