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.

67 lines
2.3 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. # 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 = u'francetvinfo.fr'
  38. _VALID_URL = r'https?://www\.francetvinfo\.fr/replay.*/(?P<title>.+).html'
  39. _TEST = {
  40. u'url': u'http://www.francetvinfo.fr/replay-jt/france-3/soir-3/jt-grand-soir-3-lundi-26-aout-2013_393427.html',
  41. u'file': u'84981923.mp4',
  42. u'info_dict': {
  43. u'title': u'Soir 3',
  44. },
  45. u'params': {
  46. u'skip_download': True,
  47. },
  48. }
  49. def _real_extract(self, url):
  50. mobj = re.match(self._VALID_URL, url)
  51. page_title = mobj.group('title')
  52. webpage = self._download_webpage(url, page_title)
  53. video_id = self._search_regex(r'id-video=(\d+?)"', webpage, u'video id')
  54. return self._extract_video(video_id)