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.

168 lines
6.4 KiB

  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. clean_html,
  7. determine_ext,
  8. unified_strdate,
  9. )
  10. class NovaIE(InfoExtractor):
  11. IE_DESC = 'TN.cz, Prásk.tv, Nova.cz, Novaplus.cz, FANDA.tv, Krásná.cz and Doma.cz'
  12. _VALID_URL = 'http://(?:[^.]+\.)?(?P<site>tv(?:noviny)?|tn|novaplus|vymena|fanda|krasna|doma|prask)\.nova\.cz/(?:[^/]+/)+(?P<id>[^/]+?)(?:\.html|/|$)'
  13. _TESTS = [{
  14. 'url': 'http://tvnoviny.nova.cz/clanek/novinky/co-na-sebe-sportaci-praskli-vime-jestli-pujde-hrdlicka-na-materskou.html?utm_source=tvnoviny&utm_medium=cpfooter&utm_campaign=novaplus',
  15. 'info_dict': {
  16. 'id': '1608920',
  17. 'display_id': 'co-na-sebe-sportaci-praskli-vime-jestli-pujde-hrdlicka-na-materskou',
  18. 'ext': 'flv',
  19. 'title': 'Duel: Michal Hrdlička a Petr Suchoň',
  20. 'description': 'md5:d0cc509858eee1b1374111c588c6f5d5',
  21. 'thumbnail': 're:^https?://.*\.(?:jpg)',
  22. },
  23. 'params': {
  24. # rtmp download
  25. 'skip_download': True,
  26. }
  27. }, {
  28. 'url': 'http://tn.nova.cz/clanek/tajemstvi-ukryte-v-podzemi-specialni-nemocnice-v-prazske-krci.html#player_13260',
  29. 'md5': '1dd7b9d5ea27bc361f110cd855a19bd3',
  30. 'info_dict': {
  31. 'id': '1757139',
  32. 'display_id': 'tajemstvi-ukryte-v-podzemi-specialni-nemocnice-v-prazske-krci',
  33. 'ext': 'mp4',
  34. 'title': 'Podzemní nemocnice v pražské Krči',
  35. 'description': 'md5:f0a42dd239c26f61c28f19e62d20ef53',
  36. 'thumbnail': 're:^https?://.*\.(?:jpg)',
  37. }
  38. }, {
  39. 'url': 'http://novaplus.nova.cz/porad/policie-modrava/video/5591-policie-modrava-15-dil-blondynka-na-hrbitove',
  40. 'info_dict': {
  41. 'id': '1756825',
  42. 'display_id': '5591-policie-modrava-15-dil-blondynka-na-hrbitove',
  43. 'ext': 'mp4',
  44. 'title': 'Policie Modrava - 15. díl - Blondýnka na hřbitově',
  45. 'description': 'md5:dc24e50be5908df83348e50d1431295e',
  46. 'thumbnail': 're:^https?://.*\.(?:jpg)',
  47. },
  48. 'params': {
  49. # rtmp download
  50. 'skip_download': True,
  51. }
  52. }, {
  53. 'url': 'http://novaplus.nova.cz/porad/televizni-noviny/video/5585-televizni-noviny-30-5-2015/',
  54. 'info_dict': {
  55. 'id': '1756858',
  56. 'ext': 'mp4',
  57. 'title': 'Televizní noviny - 30. 5. 2015',
  58. 'thumbnail': 're:^https?://.*\.(?:jpg)',
  59. 'upload_date': '20150530',
  60. },
  61. 'params': {
  62. # rtmp download
  63. 'skip_download': True,
  64. }
  65. }, {
  66. 'url': 'http://fanda.nova.cz/clanek/fun-and-games/krvavy-epos-zaklinac-3-divoky-hon-vychazi-vyhrajte-ho-pro-sebe.html',
  67. 'info_dict': {
  68. 'id': '1753621',
  69. 'ext': 'mp4',
  70. 'title': 'Zaklínač 3: Divoký hon',
  71. 'description': 're:.*Pokud se stejně jako my nemůžete.*',
  72. 'thumbnail': 're:https?://.*\.jpg(\?.*)?',
  73. 'upload_date': '20150521',
  74. },
  75. 'params': {
  76. # rtmp download
  77. 'skip_download': True,
  78. }
  79. }, {
  80. 'url': 'http://sport.tn.nova.cz/clanek/sport/hokej/nhl/zivot-jde-dal-hodnotil-po-vyrazeni-z-playoff-jiri-sekac.html',
  81. 'only_matching': True,
  82. }, {
  83. 'url': 'http://fanda.nova.cz/clanek/fun-and-games/krvavy-epos-zaklinac-3-divoky-hon-vychazi-vyhrajte-ho-pro-sebe.html',
  84. 'only_matching': True,
  85. }, {
  86. 'url': 'http://doma.nova.cz/clanek/zdravi/prijdte-se-zapsat-do-registru-kostni-drene-jiz-ve-stredu-3-cervna.html',
  87. 'only_matching': True,
  88. }, {
  89. 'url': 'http://prask.nova.cz/clanek/novinky/co-si-na-sobe-nase-hvezdy-nechaly-pojistit.html',
  90. 'only_matching': True,
  91. }, {
  92. 'url': 'http://tv.nova.cz/clanek/novinky/zivot-je-zivot-bondovsky-trailer.html',
  93. 'only_matching': True,
  94. }]
  95. def _real_extract(self, url):
  96. mobj = re.match(self._VALID_URL, url)
  97. display_id = mobj.group('id')
  98. site = mobj.group('site')
  99. webpage = self._download_webpage(url, display_id)
  100. video_id = self._search_regex(
  101. [r"(?:media|video_id)\s*:\s*'(\d+)'",
  102. r'media=(\d+)',
  103. r'id="article_video_(\d+)"',
  104. r'id="player_(\d+)"'],
  105. webpage, 'video id')
  106. config_url = self._search_regex(
  107. r'src="(http://tn\.nova\.cz/bin/player/videojs/config\.php\?[^"]+)"',
  108. webpage, 'config url', default=None)
  109. if not config_url:
  110. DEFAULT_SITE_ID = '23000'
  111. SITES = {
  112. 'tvnoviny': DEFAULT_SITE_ID,
  113. 'novaplus': DEFAULT_SITE_ID,
  114. 'vymena': DEFAULT_SITE_ID,
  115. 'krasna': DEFAULT_SITE_ID,
  116. 'fanda': '30',
  117. 'tn': '30',
  118. 'doma': '30',
  119. }
  120. site_id = self._search_regex(
  121. r'site=(\d+)', webpage, 'site id', default=None) or SITES.get(site, DEFAULT_SITE_ID)
  122. config_url = ('http://tn.nova.cz/bin/player/videojs/config.php?site=%s&media=%s&jsVar=vjsconfig'
  123. % (site_id, video_id))
  124. config = self._download_json(
  125. config_url, display_id,
  126. 'Downloading config JSON',
  127. transform_source=lambda s: s[s.index('{'):s.rindex('}') + 1])
  128. mediafile = config['mediafile']
  129. video_url = mediafile['src']
  130. ext = determine_ext(video_url)
  131. video_url = video_url.replace('&{}:'.format(ext), '')
  132. title = mediafile.get('meta', {}).get('title') or self._og_search_title(webpage)
  133. description = clean_html(self._og_search_description(webpage, default=None))
  134. thumbnail = config.get('poster')
  135. if site == 'novaplus':
  136. upload_date = unified_strdate(self._search_regex(
  137. r'(\d{1,2}-\d{1,2}-\d{4})$', display_id, 'upload date', default=None))
  138. elif site == 'fanda':
  139. upload_date = unified_strdate(self._search_regex(
  140. r'<span class="date_time">(\d{1,2}\.\d{1,2}\.\d{4})', webpage, 'upload date', default=None))
  141. else:
  142. upload_date = None
  143. return {
  144. 'id': video_id,
  145. 'display_id': display_id,
  146. 'title': title,
  147. 'description': description,
  148. 'upload_date': upload_date,
  149. 'thumbnail': thumbnail,
  150. 'url': video_url,
  151. 'ext': ext,
  152. }