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