]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/bet.py
Update list of supported sites
[youtubedl] / youtube_dl / extractor / bet.py
1 from __future__ import unicode_literals
2
3 from .mtv import MTVServicesInfoExtractor
4 from ..utils import unified_strdate
5 from ..compat import compat_urllib_parse_urlencode
6
7
8 class BetIE(MTVServicesInfoExtractor):
9 _VALID_URL = r'https?://(?:www\.)?bet\.com/(?:[^/]+/)+(?P<id>.+?)\.html'
10 _TESTS = [
11 {
12 'url': 'http://www.bet.com/news/politics/2014/12/08/in-bet-exclusive-obama-talks-race-and-racism.html',
13 'info_dict': {
14 'id': '07e96bd3-8850-3051-b856-271b457f0ab8',
15 'display_id': 'in-bet-exclusive-obama-talks-race-and-racism',
16 'ext': 'flv',
17 'title': 'A Conversation With President Obama',
18 'description': 'President Obama urges persistence in confronting racism and bias.',
19 'duration': 1534,
20 'upload_date': '20141208',
21 'thumbnail': 're:(?i)^https?://.*\.jpg$',
22 'subtitles': {
23 'en': 'mincount:2',
24 }
25 },
26 'params': {
27 # rtmp download
28 'skip_download': True,
29 },
30 },
31 {
32 'url': 'http://www.bet.com/video/news/national/2014/justice-for-ferguson-a-community-reacts.html',
33 'info_dict': {
34 'id': '9f516bf1-7543-39c4-8076-dd441b459ba9',
35 'display_id': 'justice-for-ferguson-a-community-reacts',
36 'ext': 'flv',
37 'title': 'Justice for Ferguson: A Community Reacts',
38 'description': 'A BET News special.',
39 'duration': 1696,
40 'upload_date': '20141125',
41 'thumbnail': 're:(?i)^https?://.*\.jpg$',
42 'subtitles': {
43 'en': 'mincount:2',
44 }
45 },
46 'params': {
47 # rtmp download
48 'skip_download': True,
49 },
50 }
51 ]
52
53 _FEED_URL = "http://feeds.mtvnservices.com/od/feed/bet-mrss-player"
54
55 def _get_feed_query(self, uri):
56 return compat_urllib_parse_urlencode({
57 'uuid': uri,
58 })
59
60 def _extract_mgid(self, webpage):
61 return self._search_regex(r'data-uri="([^"]+)', webpage, 'mgid')
62
63 def _real_extract(self, url):
64 display_id = self._match_id(url)
65
66 webpage = self._download_webpage(url, display_id)
67 mgid = self._extract_mgid(webpage)
68 videos_info = self._get_videos_info(mgid)
69
70 info_dict = videos_info['entries'][0]
71
72 upload_date = unified_strdate(self._html_search_meta('date', webpage))
73 description = self._html_search_meta('description', webpage)
74
75 info_dict.update({
76 'display_id': display_id,
77 'description': description,
78 'upload_date': upload_date,
79 })
80
81 return info_dict