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.

81 lines
2.7 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. get_meta_content,
  6. parse_iso8601,
  7. )
  8. class HeiseIE(InfoExtractor):
  9. _VALID_URL = r'''(?x)
  10. https?://(?:www\.)?heise\.de/video/artikel/
  11. .+?(?P<id>[0-9]+)\.html(?:$|[?#])
  12. '''
  13. _TEST = {
  14. 'url': (
  15. 'http://www.heise.de/video/artikel/Podcast-c-t-uplink-3-3-Owncloud-Tastaturen-Peilsender-Smartphone-2404147.html'
  16. ),
  17. 'md5': 'ffed432483e922e88545ad9f2f15d30e',
  18. 'info_dict': {
  19. 'id': '2404147',
  20. 'ext': 'mp4',
  21. 'title': (
  22. "Podcast: c't uplink 3.3 – Owncloud / Tastaturen / Peilsender Smartphone"
  23. ),
  24. 'format_id': 'mp4_720',
  25. 'timestamp': 1411812600,
  26. 'upload_date': '20140927',
  27. 'description': 'In uplink-Episode 3.3 geht es darum, wie man sich von Cloud-Anbietern emanzipieren kann, worauf man beim Kauf einer Tastatur achten sollte und was Smartphones über uns verraten.',
  28. }
  29. }
  30. def _real_extract(self, url):
  31. video_id = self._match_id(url)
  32. webpage = self._download_webpage(url, video_id)
  33. json_url = self._search_regex(
  34. r'json_url:\s*"([^"]+)"', webpage, 'json URL')
  35. config = self._download_json(json_url, video_id)
  36. info = {
  37. 'id': video_id,
  38. 'thumbnail': config.get('poster'),
  39. 'timestamp': parse_iso8601(get_meta_content('date', webpage)),
  40. 'description': self._og_search_description(webpage),
  41. }
  42. title = get_meta_content('fulltitle', webpage)
  43. if title:
  44. info['title'] = title
  45. elif config.get('title'):
  46. info['title'] = config['title']
  47. else:
  48. info['title'] = self._og_search_title(webpage)
  49. formats = []
  50. for t, rs in config['formats'].items():
  51. if not rs or not hasattr(rs, 'items'):
  52. self._downloader.report_warning(
  53. 'formats: {0}: no resolutions'.format(t))
  54. continue
  55. for height_str, obj in rs.items():
  56. format_id = '{0}_{1}'.format(t, height_str)
  57. if not obj or not obj.get('url'):
  58. self._downloader.report_warning(
  59. 'formats: {0}: no url'.format(format_id))
  60. continue
  61. formats.append({
  62. 'url': obj['url'],
  63. 'format_id': format_id,
  64. 'height': self._int(height_str, 'height'),
  65. })
  66. self._sort_formats(formats)
  67. info['formats'] = formats
  68. return info