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