canalc2.py 1.4 KB

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