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