logo

youtube-dl

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

vrak.py (2943B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from .brightcove import BrightcoveNewIE
  6. from ..utils import (
  7. int_or_none,
  8. parse_age_limit,
  9. smuggle_url,
  10. unescapeHTML,
  11. )
  12. class VrakIE(InfoExtractor):
  13. _VALID_URL = r'https?://(?:www\.)?vrak\.tv/videos\?.*?\btarget=(?P<id>[\d.]+)'
  14. _TEST = {
  15. 'url': 'http://www.vrak.tv/videos?target=1.2306782&filtre=emission&id=1.1806721',
  16. 'info_dict': {
  17. 'id': '5345661243001',
  18. 'ext': 'mp4',
  19. 'title': 'Obésité, film de hockey et Roseline Filion',
  20. 'timestamp': 1488492126,
  21. 'upload_date': '20170302',
  22. 'uploader_id': '2890187628001',
  23. 'creator': 'VRAK.TV',
  24. 'age_limit': 8,
  25. 'series': 'ALT (Actualité Légèrement Tordue)',
  26. 'episode': 'Obésité, film de hockey et Roseline Filion',
  27. 'tags': list,
  28. },
  29. 'params': {
  30. 'skip_download': True,
  31. },
  32. }
  33. BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/2890187628001/default_default/index.html?videoId=%s'
  34. def _real_extract(self, url):
  35. video_id = self._match_id(url)
  36. webpage = self._download_webpage(url, video_id)
  37. title = self._html_search_regex(
  38. r'<h\d\b[^>]+\bclass=["\']videoTitle["\'][^>]*>([^<]+)',
  39. webpage, 'title', default=None) or self._og_search_title(webpage)
  40. content = self._parse_json(
  41. self._search_regex(
  42. r'data-player-options-content=(["\'])(?P<content>{.+?})\1',
  43. webpage, 'content', default='{}', group='content'),
  44. video_id, transform_source=unescapeHTML)
  45. ref_id = content.get('refId') or self._search_regex(
  46. r'refId&quot;:&quot;([^&]+)&quot;', webpage, 'ref id')
  47. brightcove_id = self._search_regex(
  48. r'''(?x)
  49. java\.lang\.String\s+value\s*=\s*["']brightcove\.article\.\d+\.%s
  50. [^>]*
  51. java\.lang\.String\s+value\s*=\s*["'](\d+)
  52. ''' % re.escape(ref_id), webpage, 'brightcove id')
  53. return {
  54. '_type': 'url_transparent',
  55. 'ie_key': BrightcoveNewIE.ie_key(),
  56. 'url': smuggle_url(
  57. self.BRIGHTCOVE_URL_TEMPLATE % brightcove_id,
  58. {'geo_countries': ['CA']}),
  59. 'id': brightcove_id,
  60. 'description': content.get('description'),
  61. 'creator': content.get('brand'),
  62. 'age_limit': parse_age_limit(content.get('rating')),
  63. 'series': content.get('showName') or content.get(
  64. 'episodeName'), # this is intentional
  65. 'season_number': int_or_none(content.get('seasonNumber')),
  66. 'episode': title,
  67. 'episode_number': int_or_none(content.get('episodeNumber')),
  68. 'tags': content.get('tags', []),
  69. }