You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.8 KiB

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