logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

rds.py (2881B)


  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. # has two 9c9media ContentPackages, the web player selects the first ContentPackage
  15. 'url': 'https://www.rds.ca/videos/Hockey/NationalHockeyLeague/teams/9/forum-du-5-a-7-jesperi-kotkaniemi-de-retour-de-finlande-3.1377606',
  16. 'info_dict': {
  17. 'id': '2083309',
  18. 'display_id': 'forum-du-5-a-7-jesperi-kotkaniemi-de-retour-de-finlande',
  19. 'ext': 'flv',
  20. 'title': 'Forum du 5 à 7 : Kotkaniemi de retour de Finlande',
  21. 'description': 'md5:83fa38ecc4a79b19e433433254077f25',
  22. 'timestamp': 1606129030,
  23. 'upload_date': '20201123',
  24. 'duration': 773.039,
  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. }