]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tbs.py
Prepare to release.
[youtubedl] / youtube_dl / extractor / tbs.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .turner import TurnerBaseIE
7 from ..utils import extract_attributes
8
9
10 class TBSIE(TurnerBaseIE):
11 _VALID_URL = r'https?://(?:www\.)?(?P<site>tbs|tntdrama)\.com/videos/(?:[^/]+/)+(?P<id>[^/?#]+)\.html'
12 _TESTS = [{
13 'url': 'http://www.tbs.com/videos/people-of-earth/season-1/extras/2007318/theatrical-trailer.html',
14 'md5': '9e61d680e2285066ade7199e6408b2ee',
15 'info_dict': {
16 'id': '2007318',
17 'ext': 'mp4',
18 'title': 'Theatrical Trailer',
19 'description': 'Catch the latest comedy from TBS, People of Earth, premiering Halloween night--Monday, October 31, at 9/8c.',
20 }
21 }, {
22 'url': 'http://www.tntdrama.com/videos/good-behavior/season-1/extras/1538823/you-better-run.html',
23 'md5': 'ce53c6ead5e9f3280b4ad2031a6fab56',
24 'info_dict': {
25 'id': '1538823',
26 'ext': 'mp4',
27 'title': 'You Better Run',
28 'description': 'Letty Raines must figure out what she\'s running toward while running away from her past. Good Behavior premieres November 15 at 9/8c.',
29 }
30 }]
31
32 def _real_extract(self, url):
33 domain, display_id = re.match(self._VALID_URL, url).groups()
34 site = domain[:3]
35 webpage = self._download_webpage(url, display_id)
36 video_params = extract_attributes(self._search_regex(r'(<[^>]+id="page-video"[^>]*>)', webpage, 'video params'))
37 query = None
38 clip_id = video_params.get('clipid')
39 if clip_id:
40 query = 'id=' + clip_id
41 else:
42 query = 'titleId=' + video_params['titleid']
43 return self._extract_cvp_info(
44 'http://www.%s.com/service/cvpXml?%s' % (domain, query), display_id, {
45 'default': {
46 'media_src': 'http://ht.cdn.turner.com/%s/big' % site,
47 },
48 'secure': {
49 'media_src': 'http://androidhls-secure.cdn.turner.com/%s/big' % site,
50 'tokenizer_src': 'http://www.%s.com/video/processors/services/token_ipadAdobe.do' % domain,
51 },
52 }, {
53 'url': url,
54 'site_name': site.upper(),
55 'auth_required': video_params.get('isAuthRequired') != 'false',
56 })