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.

65 lines
2.3 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from .brightcove import BrightcoveNewIE
  6. class TVANouvellesIE(InfoExtractor):
  7. _VALID_URL = r'https?://(?:www\.)?tvanouvelles\.ca/videos/(?P<id>\d+)'
  8. _TEST = {
  9. 'url': 'http://www.tvanouvelles.ca/videos/5117035533001',
  10. 'info_dict': {
  11. 'id': '5117035533001',
  12. 'ext': 'mp4',
  13. 'title': 'L’industrie du taxi dénonce l’entente entre Québec et Uber: explications',
  14. 'description': 'md5:479653b7c8cf115747bf5118066bd8b3',
  15. 'uploader_id': '1741764581',
  16. 'timestamp': 1473352030,
  17. 'upload_date': '20160908',
  18. },
  19. 'add_ie': ['BrightcoveNew'],
  20. }
  21. BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/1741764581/default_default/index.html?videoId=%s'
  22. def _real_extract(self, url):
  23. brightcove_id = self._match_id(url)
  24. return self.url_result(
  25. self.BRIGHTCOVE_URL_TEMPLATE % brightcove_id,
  26. BrightcoveNewIE.ie_key(), brightcove_id)
  27. class TVANouvellesArticleIE(InfoExtractor):
  28. _VALID_URL = r'https?://(?:www\.)?tvanouvelles\.ca/(?:[^/]+/)+(?P<id>[^/?#&]+)'
  29. _TEST = {
  30. 'url': 'http://www.tvanouvelles.ca/2016/11/17/des-policiers-qui-ont-la-meche-un-peu-courte',
  31. 'info_dict': {
  32. 'id': 'des-policiers-qui-ont-la-meche-un-peu-courte',
  33. 'title': 'Des policiers qui ont «la mèche un peu courte»?',
  34. 'description': 'md5:92d363c8eb0f0f030de9a4a84a90a3a0',
  35. },
  36. 'playlist_mincount': 4,
  37. }
  38. @classmethod
  39. def suitable(cls, url):
  40. return False if TVANouvellesIE.suitable(url) else super(TVANouvellesArticleIE, cls).suitable(url)
  41. def _real_extract(self, url):
  42. display_id = self._match_id(url)
  43. webpage = self._download_webpage(url, display_id)
  44. entries = [
  45. self.url_result(
  46. 'http://www.tvanouvelles.ca/videos/%s' % mobj.group('id'),
  47. ie=TVANouvellesIE.ie_key(), video_id=mobj.group('id'))
  48. for mobj in re.finditer(
  49. r'data-video-id=(["\'])?(?P<id>\d+)', webpage)]
  50. title = self._og_search_title(webpage, fatal=False)
  51. description = self._og_search_description(webpage)
  52. return self.playlist_result(entries, display_id, title, description)