1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-23 02:32:16 +00:00
youtube-dl/youtube_dl/extractor/bet.py

81 lines
2.7 KiB
Python
Raw Normal View History

2014-12-09 16:29:01 +00:00
from __future__ import unicode_literals
2016-06-18 04:17:24 +00:00
from .mtv import MTVServicesInfoExtractor
from ..utils import unified_strdate
2014-12-09 16:29:01 +00:00
2016-06-18 04:17:24 +00:00
class BetIE(MTVServicesInfoExtractor):
2014-12-09 16:29:01 +00:00
_VALID_URL = r'https?://(?:www\.)?bet\.com/(?:[^/]+/)+(?P<id>.+?)\.html'
_TESTS = [
{
'url': 'http://www.bet.com/news/politics/2014/12/08/in-bet-exclusive-obama-talks-race-and-racism.html',
'info_dict': {
2016-06-18 04:17:24 +00:00
'id': '07e96bd3-8850-3051-b856-271b457f0ab8',
2014-12-09 16:29:01 +00:00
'display_id': 'in-bet-exclusive-obama-talks-race-and-racism',
'ext': 'flv',
'title': 'A Conversation With President Obama',
2016-06-18 04:17:24 +00:00
'description': 'President Obama urges persistence in confronting racism and bias.',
2014-12-09 16:29:01 +00:00
'duration': 1534,
'upload_date': '20141208',
'thumbnail': r're:(?i)^https?://.*\.jpg$',
2016-06-18 04:17:24 +00:00
'subtitles': {
'en': 'mincount:2',
}
2014-12-09 16:29:01 +00:00
},
'params': {
# rtmp download
'skip_download': True,
},
},
{
'url': 'http://www.bet.com/video/news/national/2014/justice-for-ferguson-a-community-reacts.html',
'info_dict': {
2016-06-18 04:17:24 +00:00
'id': '9f516bf1-7543-39c4-8076-dd441b459ba9',
2014-12-09 16:29:01 +00:00
'display_id': 'justice-for-ferguson-a-community-reacts',
'ext': 'flv',
'title': 'Justice for Ferguson: A Community Reacts',
'description': 'A BET News special.',
'duration': 1696,
'upload_date': '20141125',
'thumbnail': r're:(?i)^https?://.*\.jpg$',
2016-06-18 04:17:24 +00:00
'subtitles': {
'en': 'mincount:2',
}
2014-12-09 16:29:01 +00:00
},
'params': {
# rtmp download
'skip_download': True,
},
}
]
2016-06-18 04:17:24 +00:00
_FEED_URL = "http://feeds.mtvnservices.com/od/feed/bet-mrss-player"
2014-12-09 16:29:01 +00:00
2016-06-18 04:17:24 +00:00
def _get_feed_query(self, uri):
return {
2016-06-18 04:17:24 +00:00
'uuid': uri,
}
2016-06-18 04:17:24 +00:00
def _extract_mgid(self, webpage):
return self._search_regex(r'data-uri="([^"]+)', webpage, 'mgid')
2014-12-09 16:29:01 +00:00
2016-06-18 04:17:24 +00:00
def _real_extract(self, url):
display_id = self._match_id(url)
2014-12-09 16:29:01 +00:00
2016-06-18 04:17:24 +00:00
webpage = self._download_webpage(url, display_id)
mgid = self._extract_mgid(webpage)
videos_info = self._get_videos_info(mgid)
2014-12-09 16:29:01 +00:00
2016-06-18 04:17:24 +00:00
info_dict = videos_info['entries'][0]
2014-12-09 16:29:01 +00:00
2016-06-18 04:17:24 +00:00
upload_date = unified_strdate(self._html_search_meta('date', webpage))
description = self._html_search_meta('description', webpage)
2014-12-09 16:29:01 +00:00
2016-06-18 04:17:24 +00:00
info_dict.update({
2014-12-09 16:29:01 +00:00
'display_id': display_id,
'description': description,
2016-06-18 04:17:24 +00:00
'upload_date': upload_date,
})
return info_dict