rds.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. parse_duration,
  7. parse_iso8601,
  8. )
  9. class RDSIE(InfoExtractor):
  10. IE_DESC = 'RDS.ca'
  11. _VALID_URL = r'https?://(?:www\.)?rds\.ca/videos/(?:[^/]+/)+(?P<display_id>[^/]+)-(?P<id>\d+\.\d+)'
  12. _TEST = {
  13. 'url': 'http://www.rds.ca/videos/football/nfl/fowler-jr-prend-la-direction-de-jacksonville-3.1132799',
  14. 'info_dict': {
  15. 'id': '3.1132799',
  16. 'display_id': 'fowler-jr-prend-la-direction-de-jacksonville',
  17. 'ext': 'mp4',
  18. 'title': 'Fowler Jr. prend la direction de Jacksonville',
  19. 'description': 'Dante Fowler Jr. est le troisième choix du repêchage 2015 de la NFL. ',
  20. 'timestamp': 1430397346,
  21. 'upload_date': '20150430',
  22. 'duration': 154.354,
  23. 'age_limit': 0,
  24. }
  25. }
  26. def _real_extract(self, url):
  27. mobj = re.match(self._VALID_URL, url)
  28. video_id = mobj.group('id')
  29. display_id = mobj.group('display_id')
  30. webpage = self._download_webpage(url, display_id)
  31. # TODO: extract f4m from 9c9media.com
  32. video_url = self._search_regex(
  33. r'<span[^>]+itemprop="contentURL"[^>]+content="([^"]+)"',
  34. webpage, 'video url')
  35. title = self._og_search_title(webpage) or self._html_search_meta(
  36. 'title', webpage, 'title', fatal=True)
  37. description = self._og_search_description(webpage) or self._html_search_meta(
  38. 'description', webpage, 'description')
  39. thumbnail = self._og_search_thumbnail(webpage) or self._search_regex(
  40. [r'<link[^>]+itemprop="thumbnailUrl"[^>]+href="([^"]+)"',
  41. r'<span[^>]+itemprop="thumbnailUrl"[^>]+content="([^"]+)"'],
  42. webpage, 'thumbnail', fatal=False)
  43. timestamp = parse_iso8601(self._search_regex(
  44. r'<span[^>]+itemprop="uploadDate"[^>]+content="([^"]+)"',
  45. webpage, 'upload date', fatal=False))
  46. duration = parse_duration(self._search_regex(
  47. r'<span[^>]+itemprop="duration"[^>]+content="([^"]+)"',
  48. webpage, 'duration', fatal=False))
  49. age_limit = self._family_friendly_search(webpage)
  50. return {
  51. 'id': video_id,
  52. 'display_id': display_id,
  53. 'url': video_url,
  54. 'title': title,
  55. 'description': description,
  56. 'thumbnail': thumbnail,
  57. 'timestamp': timestamp,
  58. 'duration': duration,
  59. 'age_limit': age_limit,
  60. }