]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tmz.py
Update Standards-Version to 3.9.8 (no changes required).
[youtubedl] / youtube_dl / extractor / tmz.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5
6
7 class TMZIE(InfoExtractor):
8 _VALID_URL = r'https?://(?:www\.)?tmz\.com/videos/(?P<id>[^/?#]+)'
9 _TESTS = [{
10 'url': 'http://www.tmz.com/videos/0_okj015ty/',
11 'md5': '4d22a51ef205b6c06395d8394f72d560',
12 'info_dict': {
13 'id': '0_okj015ty',
14 'ext': 'mp4',
15 'title': 'Kim Kardashian\'s Boobs Unlock a Mystery!',
16 'description': 'Did Kim Kardasain try to one-up Khloe by one-upping Kylie??? Or is she just showing off her amazing boobs?',
17 'timestamp': 1394747163,
18 'uploader_id': 'batchUser',
19 'upload_date': '20140313',
20 }
21 }, {
22 'url': 'http://www.tmz.com/videos/0-cegprt2p/',
23 'only_matching': True,
24 }]
25
26 def _real_extract(self, url):
27 video_id = self._match_id(url).replace('-', '_')
28 return self.url_result('kaltura:591531:%s' % video_id, 'Kaltura', video_id)
29
30
31 class TMZArticleIE(InfoExtractor):
32 _VALID_URL = r'https?://(?:www\.)?tmz\.com/\d{4}/\d{2}/\d{2}/(?P<id>[^/]+)/?'
33 _TEST = {
34 'url': 'http://www.tmz.com/2015/04/19/bobby-brown-bobbi-kristina-awake-video-concert',
35 'md5': 'e482a414a38db73087450e3a6ce69d00',
36 'info_dict': {
37 'id': '0_6snoelag',
38 'ext': 'mp4',
39 'title': 'Bobby Brown Tells Crowd ... Bobbi Kristina is Awake',
40 'description': 'Bobby Brown stunned his audience during a concert Saturday night, when he told the crowd, "Bobbi is awake. She\'s watching me."',
41 }
42 }
43
44 def _real_extract(self, url):
45 video_id = self._match_id(url)
46
47 webpage = self._download_webpage(url, video_id)
48 embedded_video_info_str = self._html_search_regex(
49 r'tmzVideoEmbedV2\("([^)]+)"\);', webpage, 'embedded video info')
50
51 embedded_video_info = self._parse_json(
52 embedded_video_info_str, video_id,
53 transform_source=lambda s: s.replace('\\', ''))
54
55 return self.url_result(
56 'http://www.tmz.com/videos/%s/' % embedded_video_info['id'])