logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

bet.py (2783B)


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