tvanouvelles.py 2.3 KB

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