Merge branch 'miaopai' of https://github.com/xyb/youtube-dl into xyb-miaopai
[youtube-dl] / 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         if path:
26             data_src = 'http://www.trutv.com/video/cvp/v2/xml/content.xml?id=%s.xml' % path
27         else:
28             data_src = 'http://www.trutv.com/tveverywhere/services/cvpXML.do?titleId=' + video_id
29         return self._extract_cvp_info(
30             data_src, path, {
31                 'secure': {
32                     'media_src': 'http://androidhls-secure.cdn.turner.com/trutv/big',
33                     'tokenizer_src': 'http://www.trutv.com/tveverywhere/processors/services/token_ipadAdobe.do',
34                 },
35             })