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