]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/trutv.py
Fix the changelog.
[youtubedl] / youtube_dl / extractor / trutv.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .turner import TurnerBaseIE
7
8
9 class TruTVIE(TurnerBaseIE):
10 _VALID_URL = r'https?://(?:www\.)?trutv\.com(?:(?P<path>/shows/[^/]+/videos/[^/?#]+?)\.html|/full-episodes/[^/]+/(?P<id>\d+))'
11 _TEST = {
12 'url': 'http://www.trutv.com/shows/10-things/videos/you-wont-believe-these-sports-bets.html',
13 'md5': '2cdc844f317579fed1a7251b087ff417',
14 'info_dict': {
15 'id': '/shows/10-things/videos/you-wont-believe-these-sports-bets',
16 'ext': 'mp4',
17 'title': 'You Won\'t Believe These Sports Bets',
18 'description': 'Jamie Lee sits down with a bookie to discuss the bizarre world of illegal sports betting.',
19 'upload_date': '20130305',
20 }
21 }
22
23 def _real_extract(self, url):
24 path, video_id = re.match(self._VALID_URL, url).groups()
25 auth_required = False
26 if path:
27 data_src = 'http://www.trutv.com/video/cvp/v2/xml/content.xml?id=%s.xml' % path
28 else:
29 webpage = self._download_webpage(url, video_id)
30 video_id = self._search_regex(
31 r"TTV\.TVE\.episodeId\s*=\s*'([^']+)';",
32 webpage, 'video id', default=video_id)
33 auth_required = self._search_regex(
34 r'TTV\.TVE\.authRequired\s*=\s*(true|false);',
35 webpage, 'auth required', default='false') == 'true'
36 data_src = 'http://www.trutv.com/tveverywhere/services/cvpXML.do?titleId=' + video_id
37 return self._extract_cvp_info(
38 data_src, path, {
39 'secure': {
40 'media_src': 'http://androidhls-secure.cdn.turner.com/trutv/big',
41 'tokenizer_src': 'http://www.trutv.com/tveverywhere/processors/services/token_ipadAdobe.do',
42 },
43 }, {
44 'url': url,
45 'site_name': 'truTV',
46 'auth_required': auth_required,
47 })