]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tmz.py
Prepare to upload.
[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': '3316ff838ae5bb7f642537825e1e90d2',
36 'info_dict': {
37 'id': '0_6snoelag',
38 'ext': 'mov',
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 'timestamp': 1429467813,
42 'upload_date': '20150419',
43 'uploader_id': 'batchUser',
44 }
45 }
46
47 def _real_extract(self, url):
48 video_id = self._match_id(url)
49
50 webpage = self._download_webpage(url, video_id)
51 embedded_video_info = self._parse_json(self._html_search_regex(
52 r'tmzVideoEmbed\(({.+?})\);', webpage, 'embedded video info'),
53 video_id)
54
55 return self.url_result(
56 'http://www.tmz.com/videos/%s/' % embedded_video_info['id'])