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.

235 lines
8.2 KiB

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