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.

50 lines
1.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 PluzzIE(InfoExtractor):
  9. IE_NAME = u'pluzz.francetv.fr'
  10. _VALID_URL = r'https?://pluzz\.francetv\.fr/videos/(.*?)\.html'
  11. _TEST = {
  12. u'url': u'http://pluzz.francetv.fr/videos/allo_rufo_saison5_,88439064.html',
  13. u'file': u'88439064.mp4',
  14. u'info_dict': {
  15. u'title': u'Allô Rufo',
  16. u'description': u'md5:d909f1ebdf963814b65772aea250400e',
  17. },
  18. u'params': {
  19. u'skip_download': True,
  20. },
  21. }
  22. def _real_extract(self, url):
  23. title = re.match(self._VALID_URL, url).group(1)
  24. webpage = self._download_webpage(url, title)
  25. video_id = self._search_regex(
  26. r'data-diffusion="(\d+)"', webpage, 'ID')
  27. xml_desc = self._download_webpage(
  28. 'http://www.pluzz.fr/appftv/webservices/video/'
  29. 'getInfosOeuvre.php?id-diffusion='
  30. + video_id, title, 'Downloading XML config')
  31. info = xml.etree.ElementTree.fromstring(xml_desc.encode('utf-8'))
  32. manifest_url = info.find('videos/video/url').text
  33. video_url = manifest_url.replace('manifest.f4m', 'index_2_av.m3u8')
  34. video_url = video_url.replace('/z/', '/i/')
  35. thumbnail_path = info.find('image').text
  36. return {'id': video_id,
  37. 'ext': 'mp4',
  38. 'url': video_url,
  39. 'title': info.find('titre').text,
  40. 'thumbnail': compat_urlparse.urljoin(url, thumbnail_path),
  41. 'description': info.find('synopsis').text,
  42. }