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.

56 lines
1.9 KiB

10 years ago
  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. class M6IE(InfoExtractor):
  6. IE_NAME = 'm6'
  7. _VALID_URL = r'http://(?:www\.)?m6\.fr/[^/]+/videos/(?P<id>\d+)-[^\.]+\.html'
  8. _TEST = {
  9. 'url': 'http://www.m6.fr/emission-les_reines_du_shopping/videos/11323908-emeline_est_la_reine_du_shopping_sur_le_theme_ma_fete_d_8217_anniversaire.html',
  10. 'md5': '242994a87de2c316891428e0176bcb77',
  11. 'info_dict': {
  12. 'id': '11323908',
  13. 'ext': 'mp4',
  14. 'title': 'Emeline est la Reine du Shopping sur le thème « Ma fête d’anniversaire ! »',
  15. 'description': 'md5:1212ae8fb4b7baa4dc3886c5676007c2',
  16. 'duration': 100,
  17. }
  18. }
  19. def _real_extract(self, url):
  20. mobj = re.match(self._VALID_URL, url)
  21. video_id = mobj.group('id')
  22. rss = self._download_xml('http://ws.m6.fr/v1/video/info/m6/bonus/%s' % video_id, video_id,
  23. 'Downloading video RSS')
  24. title = rss.find('./channel/item/title').text
  25. description = rss.find('./channel/item/description').text
  26. thumbnail = rss.find('./channel/item/visuel_clip_big').text
  27. duration = int(rss.find('./channel/item/duration').text)
  28. view_count = int(rss.find('./channel/item/nombre_vues').text)
  29. formats = []
  30. for format_id in ['lq', 'sd', 'hq', 'hd']:
  31. video_url = rss.find('./channel/item/url_video_%s' % format_id)
  32. if video_url is None:
  33. continue
  34. formats.append({
  35. 'url': video_url.text,
  36. 'format_id': format_id,
  37. })
  38. return {
  39. 'id': video_id,
  40. 'title': title,
  41. 'description': description,
  42. 'thumbnail': thumbnail,
  43. 'duration': duration,
  44. 'view_count': view_count,
  45. 'formats': formats,
  46. }