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.

127 lines
4.2 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': '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 France2IE(FranceTVBaseInfoExtractor):
  55. IE_NAME = u'france2.fr'
  56. _VALID_URL = r'''(?x)https?://www\.france2\.fr/
  57. (?:
  58. emissions/.*?/videos/(?P<id>\d+)
  59. | emission/(?P<key>[^/?]+)
  60. )'''
  61. _TEST = {
  62. u'url': u'http://www.france2.fr/emissions/13h15-le-samedi-le-dimanche/videos/75540104',
  63. u'file': u'75540104.mp4',
  64. u'info_dict': {
  65. u'title': u'13h15, le samedi...',
  66. u'description': u'md5:2e5b58ba7a2d3692b35c792be081a03d',
  67. },
  68. u'params': {
  69. u'skip_download': True,
  70. },
  71. }
  72. def _real_extract(self, url):
  73. mobj = re.match(self._VALID_URL, url)
  74. if mobj.group('key'):
  75. webpage = self._download_webpage(url, mobj.group('key'))
  76. video_id = self._html_search_regex(
  77. r'''(?x)<div\s+class="video-player">\s*
  78. <a\s+href="http://videos.francetv.fr/video/([0-9]+)"\s+
  79. class="francetv-video-player">''',
  80. webpage, u'video ID')
  81. else:
  82. video_id = mobj.group('id')
  83. return self._extract_video(video_id)
  84. class GenerationQuoiIE(InfoExtractor):
  85. IE_NAME = u'france2.fr:generation-quoi'
  86. _VALID_URL = r'https?://generation-quoi\.france2\.fr/portrait/(?P<name>.*)(\?|$)'
  87. _TEST = {
  88. u'url': u'http://generation-quoi.france2.fr/portrait/garde-a-vous',
  89. u'file': u'k7FJX8VBcvvLmX4wA5Q.mp4',
  90. u'info_dict': {
  91. u'title': u'Génération Quoi - Garde à Vous',
  92. u'uploader': u'Génération Quoi',
  93. },
  94. u'params': {
  95. # It uses Dailymotion
  96. u'skip_download': True,
  97. },
  98. }
  99. def _real_extract(self, url):
  100. mobj = re.match(self._VALID_URL, url)
  101. name = mobj.group('name')
  102. info_url = compat_urlparse.urljoin(url, '/medias/video/%s.json' % name)
  103. info_json = self._download_webpage(info_url, name)
  104. info = json.loads(info_json)
  105. return self.url_result('http://www.dailymotion.com/video/%s' % info['id'],
  106. ie='Dailymotion')