markiza.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. import re
  2. from .common import InfoExtractor
  3. from ..compat import compat_str
  4. from ..utils import (
  5. orderedSet,
  6. parse_duration,
  7. try_get,
  8. )
  9. class MarkizaIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?videoarchiv\.markiza\.sk/(?:video/(?:[^/]+/)*|embed/)(?P<id>\d+)(?:[_/]|$)'
  11. _TESTS = [{
  12. 'url': 'http://videoarchiv.markiza.sk/video/oteckovia/84723_oteckovia-109',
  13. 'md5': 'ada4e9fad038abeed971843aa028c7b0',
  14. 'info_dict': {
  15. 'id': '139078',
  16. 'ext': 'mp4',
  17. 'title': 'Oteckovia 109',
  18. 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
  19. 'thumbnail': r're:^https?://.*\.jpg$',
  20. 'duration': 2760,
  21. },
  22. }, {
  23. 'url': 'http://videoarchiv.markiza.sk/video/televizne-noviny/televizne-noviny/85430_televizne-noviny',
  24. 'info_dict': {
  25. 'id': '85430',
  26. 'title': 'Televízne noviny',
  27. },
  28. 'playlist_count': 23,
  29. }, {
  30. 'url': 'http://videoarchiv.markiza.sk/video/oteckovia/84723',
  31. 'only_matching': True,
  32. }, {
  33. 'url': 'http://videoarchiv.markiza.sk/video/84723',
  34. 'only_matching': True,
  35. }, {
  36. 'url': 'http://videoarchiv.markiza.sk/video/filmy/85190_kamenak',
  37. 'only_matching': True,
  38. }, {
  39. 'url': 'http://videoarchiv.markiza.sk/video/reflex/zo-zakulisia/84651_pribeh-alzbetky',
  40. 'only_matching': True,
  41. }, {
  42. 'url': 'http://videoarchiv.markiza.sk/embed/85295',
  43. 'only_matching': True,
  44. }]
  45. def _real_extract(self, url):
  46. video_id = self._match_id(url)
  47. data = self._download_json(
  48. 'http://videoarchiv.markiza.sk/json/video_jwplayer7.json',
  49. video_id, query={'id': video_id})
  50. info = self._parse_jwplayer_data(data, m3u8_id='hls', mpd_id='dash')
  51. if info.get('_type') == 'playlist':
  52. info.update({
  53. 'id': video_id,
  54. 'title': try_get(
  55. data, lambda x: x['details']['name'], compat_str),
  56. })
  57. else:
  58. info['duration'] = parse_duration(
  59. try_get(data, lambda x: x['details']['duration'], compat_str))
  60. return info
  61. class MarkizaPageIE(InfoExtractor):
  62. _VALID_URL = r'https?://(?:www\.)?(?:(?:[^/]+\.)?markiza|tvnoviny)\.sk/(?:[^/]+/)*(?P<id>\d+)_'
  63. _TESTS = [{
  64. 'url': 'http://www.markiza.sk/soubiz/zahranicny/1923705_oteckovia-maju-svoj-den-ti-slavni-nie-su-o-nic-menej-rozkosni',
  65. 'md5': 'ada4e9fad038abeed971843aa028c7b0',
  66. 'info_dict': {
  67. 'id': '139355',
  68. 'ext': 'mp4',
  69. 'title': 'Oteckovia 110',
  70. 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e',
  71. 'thumbnail': r're:^https?://.*\.jpg$',
  72. 'duration': 2604,
  73. },
  74. 'params': {
  75. 'skip_download': True,
  76. },
  77. }, {
  78. 'url': 'http://dajto.markiza.sk/filmy-a-serialy/1774695_frajeri-vo-vegas',
  79. 'only_matching': True,
  80. }, {
  81. 'url': 'http://superstar.markiza.sk/aktualne/1923870_to-je-ale-telo-spevacka-ukazala-sexy-postavicku-v-bikinach',
  82. 'only_matching': True,
  83. }, {
  84. 'url': 'http://hybsa.markiza.sk/aktualne/1923790_uzasna-atmosfera-na-hybsa-v-poprade-superstaristi-si-prve-koncerty-pred-davom-ludi-poriadne-uzili',
  85. 'only_matching': True,
  86. }, {
  87. 'url': 'http://doma.markiza.sk/filmy/1885250_moja-vysnivana-svadba',
  88. 'only_matching': True,
  89. }, {
  90. 'url': 'http://www.tvnoviny.sk/domace/1923887_po-smrti-manzela-ju-cakalo-poriadne-prekvapenie',
  91. 'only_matching': True,
  92. }]
  93. @classmethod
  94. def suitable(cls, url):
  95. return False if MarkizaIE.suitable(url) else super(MarkizaPageIE, cls).suitable(url)
  96. def _real_extract(self, url):
  97. playlist_id = self._match_id(url)
  98. webpage = self._download_webpage(
  99. # Downloading for some hosts (e.g. dajto, doma) fails with 500
  100. # although everything seems to be OK, so considering 500
  101. # status code to be expected.
  102. url, playlist_id, expected_status=500)
  103. entries = [
  104. self.url_result('http://videoarchiv.markiza.sk/video/%s' % video_id)
  105. for video_id in orderedSet(re.findall(
  106. r'(?:initPlayer_|data-entity=["\']|id=["\']player_)(\d+)',
  107. webpage))]
  108. return self.playlist_result(entries, playlist_id)