]>
Commit | Line | Data |
---|---|---|
b89a9386 S |
1 | from __future__ import unicode_literals |
2 | ||
c878e635 YCH |
3 | from .mtv import MTVServicesInfoExtractor |
4 | from ..utils import unified_strdate | |
5 | from ..compat import compat_urllib_parse_urlencode | |
b89a9386 S |
6 | |
7 | ||
c878e635 | 8 | class BetIE(MTVServicesInfoExtractor): |
b89a9386 S |
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': { | |
c878e635 | 14 | 'id': '07e96bd3-8850-3051-b856-271b457f0ab8', |
b89a9386 S |
15 | 'display_id': 'in-bet-exclusive-obama-talks-race-and-racism', |
16 | 'ext': 'flv', | |
249962ff | 17 | 'title': 'A Conversation With President Obama', |
c878e635 | 18 | 'description': 'President Obama urges persistence in confronting racism and bias.', |
b89a9386 | 19 | 'duration': 1534, |
b89a9386 | 20 | 'upload_date': '20141208', |
b89a9386 | 21 | 'thumbnail': 're:(?i)^https?://.*\.jpg$', |
c878e635 YCH |
22 | 'subtitles': { |
23 | 'en': 'mincount:2', | |
24 | } | |
b89a9386 S |
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': { | |
c878e635 | 34 | 'id': '9f516bf1-7543-39c4-8076-dd441b459ba9', |
b89a9386 S |
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, | |
b89a9386 | 40 | 'upload_date': '20141125', |
b89a9386 | 41 | 'thumbnail': 're:(?i)^https?://.*\.jpg$', |
c878e635 YCH |
42 | 'subtitles': { |
43 | 'en': 'mincount:2', | |
44 | } | |
b89a9386 S |
45 | }, |
46 | 'params': { | |
47 | # rtmp download | |
48 | 'skip_download': True, | |
49 | }, | |
50 | } | |
51 | ] | |
52 | ||
c878e635 | 53 | _FEED_URL = "http://feeds.mtvnservices.com/od/feed/bet-mrss-player" |
b89a9386 | 54 | |
c878e635 YCH |
55 | def _get_feed_query(self, uri): |
56 | return compat_urllib_parse_urlencode({ | |
57 | 'uuid': uri, | |
58 | }) | |
249962ff | 59 | |
c878e635 YCH |
60 | def _extract_mgid(self, webpage): |
61 | return self._search_regex(r'data-uri="([^"]+)', webpage, 'mgid') | |
b89a9386 | 62 | |
c878e635 YCH |
63 | def _real_extract(self, url): |
64 | display_id = self._match_id(url) | |
b89a9386 | 65 | |
c878e635 YCH |
66 | webpage = self._download_webpage(url, display_id) |
67 | mgid = self._extract_mgid(webpage) | |
68 | videos_info = self._get_videos_info(mgid) | |
b89a9386 | 69 | |
c878e635 | 70 | info_dict = videos_info['entries'][0] |
b89a9386 | 71 | |
c878e635 YCH |
72 | upload_date = unified_strdate(self._html_search_meta('date', webpage)) |
73 | description = self._html_search_meta('description', webpage) | |
b89a9386 | 74 | |
c878e635 | 75 | info_dict.update({ |
b89a9386 | 76 | 'display_id': display_id, |
b89a9386 | 77 | 'description': description, |
c878e635 YCH |
78 | 'upload_date': upload_date, |
79 | }) | |
80 | ||
81 | return info_dict |