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.8 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import parse_duration
  6. class Canalc2IE(InfoExtractor):
  7. IE_NAME = 'canalc2.tv'
  8. _VALID_URL = r'https?://(?:www\.)?canalc2\.tv/video/(?P<id>\d+)'
  9. _TEST = {
  10. 'url': 'http://www.canalc2.tv/video/12163',
  11. 'md5': '060158428b650f896c542dfbb3d6487f',
  12. 'info_dict': {
  13. 'id': '12163',
  14. 'ext': 'flv',
  15. 'title': 'Terrasses du Numérique',
  16. 'duration': 122,
  17. },
  18. 'params': {
  19. 'skip_download': True, # Requires rtmpdump
  20. }
  21. }
  22. def _real_extract(self, url):
  23. video_id = self._match_id(url)
  24. webpage = self._download_webpage(url, video_id)
  25. video_url = self._search_regex(
  26. r'jwplayer\((["\'])Player\1\)\.setup\({[^}]*file\s*:\s*(["\'])(?P<file>.+?)\2',
  27. webpage, 'video_url', group='file')
  28. formats = [{'url': video_url}]
  29. if video_url.startswith('rtmp://'):
  30. rtmp = re.search(r'^(?P<url>rtmp://[^/]+/(?P<app>.+/))(?P<play_path>mp4:.+)$', video_url)
  31. formats[0].update({
  32. 'url': rtmp.group('url'),
  33. 'ext': 'flv',
  34. 'app': rtmp.group('app'),
  35. 'play_path': rtmp.group('play_path'),
  36. 'page_url': url,
  37. })
  38. title = self._html_search_regex(
  39. r'(?s)class="[^"]*col_description[^"]*">.*?<h3>(.*?)</h3>', webpage, 'title')
  40. duration = parse_duration(self._search_regex(
  41. r'id=["\']video_duree["\'][^>]*>([^<]+)',
  42. webpage, 'duration', fatal=False))
  43. return {
  44. 'id': video_id,
  45. 'title': title,
  46. 'duration': duration,
  47. 'formats': formats,
  48. }