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.

70 lines
2.7 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. parse_duration,
  6. parse_iso8601,
  7. js_to_json,
  8. )
  9. from ..compat import compat_str
  10. class RDSIE(InfoExtractor):
  11. IE_DESC = 'RDS.ca'
  12. _VALID_URL = r'https?://(?:www\.)?rds\.ca/vid(?:[eé]|%C3%A9)os/(?:[^/]+/)*(?P<id>[^/]+)-\d+\.\d+'
  13. _TESTS = [{
  14. 'url': 'http://www.rds.ca/videos/football/nfl/fowler-jr-prend-la-direction-de-jacksonville-3.1132799',
  15. 'info_dict': {
  16. 'id': '604333',
  17. 'display_id': 'fowler-jr-prend-la-direction-de-jacksonville',
  18. 'ext': 'flv',
  19. 'title': 'Fowler Jr. prend la direction de Jacksonville',
  20. 'description': 'Dante Fowler Jr. est le troisième choix du repêchage 2015 de la NFL. ',
  21. 'timestamp': 1430397346,
  22. 'upload_date': '20150430',
  23. 'duration': 154.354,
  24. 'age_limit': 0,
  25. }
  26. }, {
  27. 'url': 'http://www.rds.ca/vid%C3%A9os/un-voyage-positif-3.877934',
  28. 'only_matching': True,
  29. }]
  30. def _real_extract(self, url):
  31. display_id = self._match_id(url)
  32. webpage = self._download_webpage(url, display_id)
  33. item = self._parse_json(self._search_regex(r'(?s)itemToPush\s*=\s*({.+?});', webpage, 'item'), display_id, js_to_json)
  34. video_id = compat_str(item['id'])
  35. title = item.get('title') or 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 = item.get('urlImageBig') or 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. '_type': 'url_transparent',
  52. 'id': video_id,
  53. 'display_id': display_id,
  54. 'url': '9c9media:rds_web:%s' % video_id,
  55. 'title': title,
  56. 'description': description,
  57. 'thumbnail': thumbnail,
  58. 'timestamp': timestamp,
  59. 'duration': duration,
  60. 'age_limit': age_limit,
  61. 'ie_key': 'NineCNineMedia',
  62. }