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.

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