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.

73 lines
2.7 KiB

9 years ago
9 years ago
9 years ago
9 years ago
  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/vid(?:[eé]|%C3%A9)os/(?:[^/]+/)*(?P<display_id>[^/]+)-(?P<id>\d+\.\d+)'
  12. _TESTS = [{
  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. 'url': 'http://www.rds.ca/vid%C3%A9os/un-voyage-positif-3.877934',
  27. 'only_matching': True,
  28. }]
  29. def _real_extract(self, url):
  30. mobj = re.match(self._VALID_URL, url)
  31. video_id = mobj.group('id')
  32. display_id = mobj.group('display_id')
  33. webpage = self._download_webpage(url, display_id)
  34. # TODO: extract f4m from 9c9media.com
  35. video_url = self._search_regex(
  36. r'<span[^>]+itemprop="contentURL"[^>]+content="([^"]+)"',
  37. webpage, 'video url')
  38. title = self._og_search_title(webpage) or self._html_search_meta(
  39. 'title', webpage, 'title', fatal=True)
  40. description = self._og_search_description(webpage) or self._html_search_meta(
  41. 'description', webpage, 'description')
  42. thumbnail = self._og_search_thumbnail(webpage) or self._search_regex(
  43. [r'<link[^>]+itemprop="thumbnailUrl"[^>]+href="([^"]+)"',
  44. r'<span[^>]+itemprop="thumbnailUrl"[^>]+content="([^"]+)"'],
  45. webpage, 'thumbnail', fatal=False)
  46. timestamp = parse_iso8601(self._search_regex(
  47. r'<span[^>]+itemprop="uploadDate"[^>]+content="([^"]+)"',
  48. webpage, 'upload date', fatal=False))
  49. duration = parse_duration(self._search_regex(
  50. r'<span[^>]+itemprop="duration"[^>]+content="([^"]+)"',
  51. webpage, 'duration', fatal=False))
  52. age_limit = self._family_friendly_search(webpage)
  53. return {
  54. 'id': video_id,
  55. 'display_id': display_id,
  56. 'url': video_url,
  57. 'title': title,
  58. 'description': description,
  59. 'thumbnail': thumbnail,
  60. 'timestamp': timestamp,
  61. 'duration': duration,
  62. 'age_limit': age_limit,
  63. }