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.

77 lines
2.6 KiB

  1. # encoding: utf-8
  2. import re
  3. import xml.etree.ElementTree
  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. xml_desc = self._download_webpage(
  11. 'http://www.francetvinfo.fr/appftv/webservices/video/'
  12. 'getInfosOeuvre.php?id-diffusion='
  13. + video_id, video_id, 'Downloading XML config')
  14. info = xml.etree.ElementTree.fromstring(xml_desc.encode('utf-8'))
  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': '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 = u'pluzz.francetv.fr'
  28. _VALID_URL = r'https?://pluzz\.francetv\.fr/videos/(.*?)\.html'
  29. _TEST = {
  30. u'url': u'http://pluzz.francetv.fr/videos/allo_rufo_saison5_,88439064.html',
  31. u'file': u'88439064.mp4',
  32. u'info_dict': {
  33. u'title': u'Allô Rufo',
  34. u'description': u'md5:d909f1ebdf963814b65772aea250400e',
  35. },
  36. u'params': {
  37. u'skip_download': True,
  38. },
  39. }
  40. def _real_extract(self, url):
  41. title = re.match(self._VALID_URL, url).group(1)
  42. webpage = self._download_webpage(url, title)
  43. video_id = self._search_regex(
  44. r'data-diffusion="(\d+)"', webpage, 'ID')
  45. return self._extract_video(video_id)
  46. class FranceTvInfoIE(FranceTVBaseInfoExtractor):
  47. IE_NAME = u'francetvinfo.fr'
  48. _VALID_URL = r'https?://www\.francetvinfo\.fr/replay.*/(?P<title>.+).html'
  49. _TEST = {
  50. u'url': u'http://www.francetvinfo.fr/replay-jt/france-3/soir-3/jt-grand-soir-3-lundi-26-aout-2013_393427.html',
  51. u'file': u'84981923.mp4',
  52. u'info_dict': {
  53. u'title': u'Soir 3',
  54. },
  55. u'params': {
  56. u'skip_download': True,
  57. },
  58. }
  59. def _real_extract(self, url):
  60. mobj = re.match(self._VALID_URL, url)
  61. page_title = mobj.group('title')
  62. webpage = self._download_webpage(url, page_title)
  63. video_id = self._search_regex(r'id-video=(\d+?)"', webpage, u'video id')
  64. return self._extract_video(video_id)