logo

youtube-dl

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

bleacherreport.py (4370B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from .amp import AMPIE
  5. from ..utils import (
  6. ExtractorError,
  7. int_or_none,
  8. parse_iso8601,
  9. )
  10. class BleacherReportIE(InfoExtractor):
  11. _VALID_URL = r'https?://(?:www\.)?bleacherreport\.com/articles/(?P<id>\d+)'
  12. _TESTS = [{
  13. 'url': 'http://bleacherreport.com/articles/2496438-fsu-stat-projections-is-jalen-ramsey-best-defensive-player-in-college-football',
  14. 'md5': 'a3ffc3dc73afdbc2010f02d98f990f20',
  15. 'info_dict': {
  16. 'id': '2496438',
  17. 'ext': 'mp4',
  18. 'title': 'FSU Stat Projections: Is Jalen Ramsey Best Defensive Player in College Football?',
  19. 'uploader_id': 3992341,
  20. 'description': 'CFB, ACC, Florida State',
  21. 'timestamp': 1434380212,
  22. 'upload_date': '20150615',
  23. 'uploader': 'Team Stream Now ',
  24. },
  25. 'add_ie': ['Ooyala'],
  26. }, {
  27. 'url': 'http://bleacherreport.com/articles/2586817-aussie-golfers-get-fright-of-their-lives-after-being-chased-by-angry-kangaroo',
  28. 'md5': '6a5cd403418c7b01719248ca97fb0692',
  29. 'info_dict': {
  30. 'id': '2586817',
  31. 'ext': 'webm',
  32. 'title': 'Aussie Golfers Get Fright of Their Lives After Being Chased by Angry Kangaroo',
  33. 'timestamp': 1446839961,
  34. 'uploader': 'Sean Fay',
  35. 'description': 'md5:b1601e2314c4d8eec23b6eafe086a757',
  36. 'uploader_id': 6466954,
  37. 'upload_date': '20151011',
  38. },
  39. 'add_ie': ['Youtube'],
  40. }]
  41. def _real_extract(self, url):
  42. article_id = self._match_id(url)
  43. article_data = self._download_json('http://api.bleacherreport.com/api/v1/articles/%s' % article_id, article_id)['article']
  44. thumbnails = []
  45. primary_photo = article_data.get('primaryPhoto')
  46. if primary_photo:
  47. thumbnails = [{
  48. 'url': primary_photo['url'],
  49. 'width': primary_photo.get('width'),
  50. 'height': primary_photo.get('height'),
  51. }]
  52. info = {
  53. '_type': 'url_transparent',
  54. 'id': article_id,
  55. 'title': article_data['title'],
  56. 'uploader': article_data.get('author', {}).get('name'),
  57. 'uploader_id': article_data.get('authorId'),
  58. 'timestamp': parse_iso8601(article_data.get('createdAt')),
  59. 'thumbnails': thumbnails,
  60. 'comment_count': int_or_none(article_data.get('commentsCount')),
  61. 'view_count': int_or_none(article_data.get('hitCount')),
  62. }
  63. video = article_data.get('video')
  64. if video:
  65. video_type = video['type']
  66. if video_type in ('cms.bleacherreport.com', 'vid.bleacherreport.com'):
  67. info['url'] = 'http://bleacherreport.com/video_embed?id=%s' % video['id']
  68. elif video_type == 'ooyala.com':
  69. info['url'] = 'ooyala:%s' % video['id']
  70. elif video_type == 'youtube.com':
  71. info['url'] = video['id']
  72. elif video_type == 'vine.co':
  73. info['url'] = 'https://vine.co/v/%s' % video['id']
  74. else:
  75. info['url'] = video_type + video['id']
  76. return info
  77. else:
  78. raise ExtractorError('no video in the article', expected=True)
  79. class BleacherReportCMSIE(AMPIE):
  80. _VALID_URL = r'https?://(?:www\.)?bleacherreport\.com/video_embed\?id=(?P<id>[0-9a-f-]{36}|\d{5})'
  81. _TESTS = [{
  82. 'url': 'http://bleacherreport.com/video_embed?id=8fd44c2f-3dc5-4821-9118-2c825a98c0e1&library=video-cms',
  83. 'md5': '670b2d73f48549da032861130488c681',
  84. 'info_dict': {
  85. 'id': '8fd44c2f-3dc5-4821-9118-2c825a98c0e1',
  86. 'ext': 'mp4',
  87. 'title': 'Cena vs. Rollins Would Expose the Heavyweight Division',
  88. 'description': 'md5:984afb4ade2f9c0db35f3267ed88b36e',
  89. 'upload_date': '20150723',
  90. 'timestamp': 1437679032,
  91. },
  92. 'expected_warnings': [
  93. 'Unable to download f4m manifest'
  94. ]
  95. }]
  96. def _real_extract(self, url):
  97. video_id = self._match_id(url)
  98. info = self._extract_feed_info('http://vid.bleacherreport.com/videos/%s.akamai' % video_id)
  99. info['id'] = video_id
  100. return info