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.

53 lines
2.0 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import merge_dicts
  6. class MallTVIE(InfoExtractor):
  7. _VALID_URL = r'https?://(?:www\.)?mall\.tv/(?:[^/]+/)*(?P<id>[^/?#&]+)'
  8. _TESTS = [{
  9. 'url': 'https://www.mall.tv/18-miliard-pro-neziskovky-opravdu-jsou-sportovci-nebo-clovek-v-tisni-pijavice',
  10. 'md5': '1c4a37f080e1f3023103a7b43458e518',
  11. 'info_dict': {
  12. 'id': 't0zzt0',
  13. 'display_id': '18-miliard-pro-neziskovky-opravdu-jsou-sportovci-nebo-clovek-v-tisni-pijavice',
  14. 'ext': 'mp4',
  15. 'title': '18 miliard pro neziskovky. Opravdu jsou sportovci nebo Člověk v tísni pijavice?',
  16. 'description': 'md5:25fc0ec42a72ba602b602c683fa29deb',
  17. 'duration': 216,
  18. 'timestamp': 1538870400,
  19. 'upload_date': '20181007',
  20. 'view_count': int,
  21. }
  22. }, {
  23. 'url': 'https://www.mall.tv/kdo-to-plati/18-miliard-pro-neziskovky-opravdu-jsou-sportovci-nebo-clovek-v-tisni-pijavice',
  24. 'only_matching': True,
  25. }]
  26. def _real_extract(self, url):
  27. display_id = self._match_id(url)
  28. webpage = self._download_webpage(
  29. url, display_id, headers=self.geo_verification_headers())
  30. SOURCE_RE = r'(<source[^>]+\bsrc=(?:(["\'])(?:(?!\2).)+|[^\s]+)/(?P<id>[\da-z]+)/index)\b'
  31. video_id = self._search_regex(
  32. SOURCE_RE, webpage, 'video id', group='id')
  33. media = self._parse_html5_media_entries(
  34. url, re.sub(SOURCE_RE, r'\1.m3u8', webpage), video_id,
  35. m3u8_id='hls', m3u8_entry_protocol='m3u8_native')[0]
  36. info = self._search_json_ld(webpage, video_id, default={})
  37. return merge_dicts(media, info, {
  38. 'id': video_id,
  39. 'display_id': display_id,
  40. 'title': self._og_search_title(webpage, default=None) or display_id,
  41. 'description': self._og_search_description(webpage, default=None),
  42. 'thumbnail': self._og_search_thumbnail(webpage, default=None),
  43. })