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