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.

193 lines
6.7 KiB

  1. # encoding: utf-8
  2. import re
  3. import json
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. compat_urlparse,
  7. )
  8. class FranceTVBaseInfoExtractor(InfoExtractor):
  9. def _extract_video(self, video_id):
  10. info = self._download_xml(
  11. 'http://www.francetvinfo.fr/appftv/webservices/video/'
  12. 'getInfosOeuvre.php?id-diffusion='
  13. + video_id, video_id, 'Downloading XML config')
  14. manifest_url = info.find('videos/video/url').text
  15. video_url = manifest_url.replace('manifest.f4m', 'index_2_av.m3u8')
  16. video_url = video_url.replace('/z/', '/i/')
  17. thumbnail_path = info.find('image').text
  18. return {'id': video_id,
  19. 'ext': 'flv' if video_url.startswith('rtmp') else 'mp4',
  20. 'url': video_url,
  21. 'title': info.find('titre').text,
  22. 'thumbnail': compat_urlparse.urljoin('http://pluzz.francetv.fr', thumbnail_path),
  23. 'description': info.find('synopsis').text,
  24. }
  25. class PluzzIE(FranceTVBaseInfoExtractor):
  26. IE_NAME = u'pluzz.francetv.fr'
  27. _VALID_URL = r'https?://pluzz\.francetv\.fr/videos/(.*?)\.html'
  28. # Can't use tests, videos expire in 7 days
  29. def _real_extract(self, url):
  30. title = re.match(self._VALID_URL, url).group(1)
  31. webpage = self._download_webpage(url, title)
  32. video_id = self._search_regex(
  33. r'data-diffusion="(\d+)"', webpage, 'ID')
  34. return self._extract_video(video_id)
  35. class FranceTvInfoIE(FranceTVBaseInfoExtractor):
  36. IE_NAME = u'francetvinfo.fr'
  37. _VALID_URL = r'https?://www\.francetvinfo\.fr/replay.*/(?P<title>.+)\.html'
  38. _TEST = {
  39. u'url': u'http://www.francetvinfo.fr/replay-jt/france-3/soir-3/jt-grand-soir-3-lundi-26-aout-2013_393427.html',
  40. u'file': u'84981923.mp4',
  41. u'info_dict': {
  42. u'title': u'Soir 3',
  43. },
  44. u'params': {
  45. u'skip_download': True,
  46. },
  47. }
  48. def _real_extract(self, url):
  49. mobj = re.match(self._VALID_URL, url)
  50. page_title = mobj.group('title')
  51. webpage = self._download_webpage(url, page_title)
  52. video_id = self._search_regex(r'id-video=(\d+?)"', webpage, u'video id')
  53. return self._extract_video(video_id)
  54. class FranceTVIE(FranceTVBaseInfoExtractor):
  55. IE_NAME = u'francetv'
  56. IE_DESC = u'France 2, 3, 4, 5 and Ô'
  57. _VALID_URL = r'''(?x)https?://www\.france[2345o]\.fr/
  58. (?:
  59. emissions/.*?/(videos|emissions)/(?P<id>[^/?]+)
  60. | (emissions?|jt)/(?P<key>[^/?]+)
  61. )'''
  62. _TESTS = [
  63. # france2
  64. {
  65. u'url': u'http://www.france2.fr/emissions/13h15-le-samedi-le-dimanche/videos/75540104',
  66. u'file': u'75540104.mp4',
  67. u'info_dict': {
  68. u'title': u'13h15, le samedi...',
  69. u'description': u'md5:2e5b58ba7a2d3692b35c792be081a03d',
  70. },
  71. u'params': {
  72. # m3u8 download
  73. u'skip_download': True,
  74. },
  75. },
  76. # france3
  77. {
  78. u'url': u'http://www.france3.fr/emissions/pieces-a-conviction/diffusions/13-11-2013_145575',
  79. u'info_dict': {
  80. u'id': u'000702326_CAPP_PicesconvictionExtrait313022013_120220131722_Au',
  81. u'ext': u'flv',
  82. u'title': u'Le scandale du prix des médicaments',
  83. u'description': u'md5:1384089fbee2f04fc6c9de025ee2e9ce',
  84. },
  85. u'params': {
  86. # rtmp download
  87. u'skip_download': True,
  88. },
  89. },
  90. # france4
  91. {
  92. u'url': u'http://www.france4.fr/emissions/hero-corp/videos/rhozet_herocorp_bonus_1_20131106_1923_06112013172108_F4',
  93. u'info_dict': {
  94. u'id': u'rhozet_herocorp_bonus_1_20131106_1923_06112013172108_F4',
  95. u'ext': u'flv',
  96. u'title': u'Hero Corp Making of - Extrait 1',
  97. u'description': u'md5:c87d54871b1790679aec1197e73d650a',
  98. },
  99. u'params': {
  100. # rtmp download
  101. u'skip_download': True,
  102. },
  103. },
  104. # france5
  105. {
  106. u'url': u'http://www.france5.fr/emissions/c-a-dire/videos/92837968',
  107. u'info_dict': {
  108. u'id': u'92837968',
  109. u'ext': u'mp4',
  110. u'title': u'C à dire ?!',
  111. u'description': u'md5:fb1db1cbad784dcce7c7a7bd177c8e2f',
  112. },
  113. u'params': {
  114. # m3u8 download
  115. u'skip_download': True,
  116. },
  117. },
  118. # franceo
  119. {
  120. u'url': u'http://www.franceo.fr/jt/info-afrique/04-12-2013',
  121. u'info_dict': {
  122. u'id': u'92327925',
  123. u'ext': u'mp4',
  124. u'title': u'Infô-Afrique',
  125. u'description': u'md5:ebf346da789428841bee0fd2a935ea55',
  126. },
  127. u'params': {
  128. # m3u8 download
  129. u'skip_download': True,
  130. },
  131. u'skip': u'The id changes frequently',
  132. },
  133. ]
  134. def _real_extract(self, url):
  135. mobj = re.match(self._VALID_URL, url)
  136. if mobj.group('key'):
  137. webpage = self._download_webpage(url, mobj.group('key'))
  138. id_res = [
  139. (r'''(?x)<div\s+class="video-player">\s*
  140. <a\s+href="http://videos.francetv.fr/video/([0-9]+)"\s+
  141. class="francetv-video-player">'''),
  142. (r'<a id="player_direct" href="http://info\.francetelevisions'
  143. '\.fr/\?id-video=([^"/&]+)'),
  144. (r'<a class="video" id="ftv_player_(.+?)"'),
  145. ]
  146. video_id = self._html_search_regex(id_res, webpage, u'video ID')
  147. else:
  148. video_id = mobj.group('id')
  149. return self._extract_video(video_id)
  150. class GenerationQuoiIE(InfoExtractor):
  151. IE_NAME = u'france2.fr:generation-quoi'
  152. _VALID_URL = r'https?://generation-quoi\.france2\.fr/portrait/(?P<name>.*)(\?|$)'
  153. _TEST = {
  154. u'url': u'http://generation-quoi.france2.fr/portrait/garde-a-vous',
  155. u'file': u'k7FJX8VBcvvLmX4wA5Q.mp4',
  156. u'info_dict': {
  157. u'title': u'Génération Quoi - Garde à Vous',
  158. u'uploader': u'Génération Quoi',
  159. },
  160. u'params': {
  161. # It uses Dailymotion
  162. u'skip_download': True,
  163. },
  164. }
  165. def _real_extract(self, url):
  166. mobj = re.match(self._VALID_URL, url)
  167. name = mobj.group('name')
  168. info_url = compat_urlparse.urljoin(url, '/medias/video/%s.json' % name)
  169. info_json = self._download_webpage(info_url, name)
  170. info = json.loads(info_json)
  171. return self.url_result('http://www.dailymotion.com/video/%s' % info['id'],
  172. ie='Dailymotion')