[bet] Moved to MTVServices
This commit is contained in:
		
							parent
							
								
									0f47cc2e92
								
							
						
					
					
						commit
						c878e635de
					
				@ -1,31 +1,27 @@
 | 
				
			|||||||
from __future__ import unicode_literals
 | 
					from __future__ import unicode_literals
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .common import InfoExtractor
 | 
					from .mtv import MTVServicesInfoExtractor
 | 
				
			||||||
from ..compat import compat_urllib_parse_unquote
 | 
					from ..utils import unified_strdate
 | 
				
			||||||
from ..utils import (
 | 
					from ..compat import compat_urllib_parse_urlencode
 | 
				
			||||||
    xpath_text,
 | 
					 | 
				
			||||||
    xpath_with_ns,
 | 
					 | 
				
			||||||
    int_or_none,
 | 
					 | 
				
			||||||
    parse_iso8601,
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class BetIE(InfoExtractor):
 | 
					class BetIE(MTVServicesInfoExtractor):
 | 
				
			||||||
    _VALID_URL = r'https?://(?:www\.)?bet\.com/(?:[^/]+/)+(?P<id>.+?)\.html'
 | 
					    _VALID_URL = r'https?://(?:www\.)?bet\.com/(?:[^/]+/)+(?P<id>.+?)\.html'
 | 
				
			||||||
    _TESTS = [
 | 
					    _TESTS = [
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            'url': 'http://www.bet.com/news/politics/2014/12/08/in-bet-exclusive-obama-talks-race-and-racism.html',
 | 
					            'url': 'http://www.bet.com/news/politics/2014/12/08/in-bet-exclusive-obama-talks-race-and-racism.html',
 | 
				
			||||||
            'info_dict': {
 | 
					            'info_dict': {
 | 
				
			||||||
                'id': 'news/national/2014/a-conversation-with-president-obama',
 | 
					                'id': '07e96bd3-8850-3051-b856-271b457f0ab8',
 | 
				
			||||||
                'display_id': 'in-bet-exclusive-obama-talks-race-and-racism',
 | 
					                'display_id': 'in-bet-exclusive-obama-talks-race-and-racism',
 | 
				
			||||||
                'ext': 'flv',
 | 
					                'ext': 'flv',
 | 
				
			||||||
                'title': 'A Conversation With President Obama',
 | 
					                'title': 'A Conversation With President Obama',
 | 
				
			||||||
                'description': 'md5:699d0652a350cf3e491cd15cc745b5da',
 | 
					                'description': 'President Obama urges persistence in confronting racism and bias.',
 | 
				
			||||||
                'duration': 1534,
 | 
					                'duration': 1534,
 | 
				
			||||||
                'timestamp': 1418075340,
 | 
					 | 
				
			||||||
                'upload_date': '20141208',
 | 
					                'upload_date': '20141208',
 | 
				
			||||||
                'uploader': 'admin',
 | 
					 | 
				
			||||||
                'thumbnail': 're:(?i)^https?://.*\.jpg$',
 | 
					                'thumbnail': 're:(?i)^https?://.*\.jpg$',
 | 
				
			||||||
 | 
					                'subtitles': {
 | 
				
			||||||
 | 
					                    'en': 'mincount:2',
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            'params': {
 | 
					            'params': {
 | 
				
			||||||
                # rtmp download
 | 
					                # rtmp download
 | 
				
			||||||
@ -35,16 +31,17 @@ class BetIE(InfoExtractor):
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            'url': 'http://www.bet.com/video/news/national/2014/justice-for-ferguson-a-community-reacts.html',
 | 
					            'url': 'http://www.bet.com/video/news/national/2014/justice-for-ferguson-a-community-reacts.html',
 | 
				
			||||||
            'info_dict': {
 | 
					            'info_dict': {
 | 
				
			||||||
                'id': 'news/national/2014/justice-for-ferguson-a-community-reacts',
 | 
					                'id': '9f516bf1-7543-39c4-8076-dd441b459ba9',
 | 
				
			||||||
                'display_id': 'justice-for-ferguson-a-community-reacts',
 | 
					                'display_id': 'justice-for-ferguson-a-community-reacts',
 | 
				
			||||||
                'ext': 'flv',
 | 
					                'ext': 'flv',
 | 
				
			||||||
                'title': 'Justice for Ferguson: A Community Reacts',
 | 
					                'title': 'Justice for Ferguson: A Community Reacts',
 | 
				
			||||||
                'description': 'A BET News special.',
 | 
					                'description': 'A BET News special.',
 | 
				
			||||||
                'duration': 1696,
 | 
					                'duration': 1696,
 | 
				
			||||||
                'timestamp': 1416942360,
 | 
					 | 
				
			||||||
                'upload_date': '20141125',
 | 
					                'upload_date': '20141125',
 | 
				
			||||||
                'uploader': 'admin',
 | 
					 | 
				
			||||||
                'thumbnail': 're:(?i)^https?://.*\.jpg$',
 | 
					                'thumbnail': 're:(?i)^https?://.*\.jpg$',
 | 
				
			||||||
 | 
					                'subtitles': {
 | 
				
			||||||
 | 
					                    'en': 'mincount:2',
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            'params': {
 | 
					            'params': {
 | 
				
			||||||
                # rtmp download
 | 
					                # rtmp download
 | 
				
			||||||
@ -53,57 +50,32 @@ class BetIE(InfoExtractor):
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    _FEED_URL = "http://feeds.mtvnservices.com/od/feed/bet-mrss-player"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def _get_feed_query(self, uri):
 | 
				
			||||||
 | 
					        return compat_urllib_parse_urlencode({
 | 
				
			||||||
 | 
					            'uuid': uri,
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def _extract_mgid(self, webpage):
 | 
				
			||||||
 | 
					        return self._search_regex(r'data-uri="([^"]+)', webpage, 'mgid')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _real_extract(self, url):
 | 
					    def _real_extract(self, url):
 | 
				
			||||||
        display_id = self._match_id(url)
 | 
					        display_id = self._match_id(url)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        webpage = self._download_webpage(url, display_id)
 | 
					        webpage = self._download_webpage(url, display_id)
 | 
				
			||||||
 | 
					        mgid = self._extract_mgid(webpage)
 | 
				
			||||||
 | 
					        videos_info = self._get_videos_info(mgid)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        media_url = compat_urllib_parse_unquote(self._search_regex(
 | 
					        info_dict = videos_info['entries'][0]
 | 
				
			||||||
            [r'mediaURL\s*:\s*"([^"]+)"', r"var\s+mrssMediaUrl\s*=\s*'([^']+)'"],
 | 
					 | 
				
			||||||
            webpage, 'media URL'))
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        video_id = self._search_regex(
 | 
					        upload_date = unified_strdate(self._html_search_meta('date', webpage))
 | 
				
			||||||
            r'/video/(.*)/_jcr_content/', media_url, 'video id')
 | 
					        description = self._html_search_meta('description', webpage)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        mrss = self._download_xml(media_url, display_id)
 | 
					        info_dict.update({
 | 
				
			||||||
 | 
					 | 
				
			||||||
        item = mrss.find('./channel/item')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        NS_MAP = {
 | 
					 | 
				
			||||||
            'dc': 'http://purl.org/dc/elements/1.1/',
 | 
					 | 
				
			||||||
            'media': 'http://search.yahoo.com/mrss/',
 | 
					 | 
				
			||||||
            'ka': 'http://kickapps.com/karss',
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        title = xpath_text(item, './title', 'title')
 | 
					 | 
				
			||||||
        description = xpath_text(
 | 
					 | 
				
			||||||
            item, './description', 'description', fatal=False)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        timestamp = parse_iso8601(xpath_text(
 | 
					 | 
				
			||||||
            item, xpath_with_ns('./dc:date', NS_MAP),
 | 
					 | 
				
			||||||
            'upload date', fatal=False))
 | 
					 | 
				
			||||||
        uploader = xpath_text(
 | 
					 | 
				
			||||||
            item, xpath_with_ns('./dc:creator', NS_MAP),
 | 
					 | 
				
			||||||
            'uploader', fatal=False)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        media_content = item.find(
 | 
					 | 
				
			||||||
            xpath_with_ns('./media:content', NS_MAP))
 | 
					 | 
				
			||||||
        duration = int_or_none(media_content.get('duration'))
 | 
					 | 
				
			||||||
        smil_url = media_content.get('url')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        thumbnail = media_content.find(
 | 
					 | 
				
			||||||
            xpath_with_ns('./media:thumbnail', NS_MAP)).get('url')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        formats = self._extract_smil_formats(smil_url, display_id)
 | 
					 | 
				
			||||||
        self._sort_formats(formats)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return {
 | 
					 | 
				
			||||||
            'id': video_id,
 | 
					 | 
				
			||||||
            'display_id': display_id,
 | 
					            'display_id': display_id,
 | 
				
			||||||
            'title': title,
 | 
					 | 
				
			||||||
            'description': description,
 | 
					            'description': description,
 | 
				
			||||||
            'thumbnail': thumbnail,
 | 
					            'upload_date': upload_date,
 | 
				
			||||||
            'timestamp': timestamp,
 | 
					        })
 | 
				
			||||||
            'uploader': uploader,
 | 
					
 | 
				
			||||||
            'duration': duration,
 | 
					        return info_dict
 | 
				
			||||||
            'formats': formats,
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user