]>
Commit | Line | Data |
---|---|---|
e232f787 PH |
1 | import json |
2 | import re | |
3 | ||
4 | from .common import InfoExtractor | |
e793338c | 5 | from .facebook import FacebookIE |
e232f787 PH |
6 | |
7 | ||
8 | class BuzzFeedIE(InfoExtractor): | |
9 | _VALID_URL = r'https?://(?:www\.)?buzzfeed\.com/[^?#]*?/(?P<id>[^?#]+)' | |
4207558e | 10 | _TESTS = [{ |
e232f787 PH |
11 | 'url': 'http://www.buzzfeed.com/abagg/this-angry-ram-destroys-a-punching-bag-like-a-boss?utm_term=4ldqpia', |
12 | 'info_dict': { | |
13 | 'id': 'this-angry-ram-destroys-a-punching-bag-like-a-boss', | |
14 | 'title': 'This Angry Ram Destroys A Punching Bag Like A Boss', | |
15 | 'description': 'Rambro!', | |
16 | }, | |
17 | 'playlist': [{ | |
18 | 'info_dict': { | |
19 | 'id': 'aVCR29aE_OQ', | |
20 | 'ext': 'mp4', | |
e793338c YCH |
21 | 'title': 'Angry Ram destroys a punching bag..', |
22 | 'description': 'md5:c59533190ef23fd4458a5e8c8c872345', | |
e232f787 PH |
23 | 'upload_date': '20141024', |
24 | 'uploader_id': 'Buddhanz1', | |
e793338c | 25 | 'uploader': 'Angry Ram', |
e232f787 PH |
26 | } |
27 | }] | |
4207558e PH |
28 | }, { |
29 | 'url': 'http://www.buzzfeed.com/sheridanwatson/look-at-this-cute-dog-omg?utm_term=4ldqpia', | |
30 | 'params': { | |
31 | 'skip_download': True, # Got enough YouTube download tests | |
32 | }, | |
33 | 'info_dict': { | |
6e99868e | 34 | 'id': 'look-at-this-cute-dog-omg', |
db6e6250 | 35 | 'description': 're:Munchkin the Teddy Bear is back ?!', |
4207558e PH |
36 | 'title': 'You Need To Stop What You\'re Doing And Watching This Dog Walk On A Treadmill', |
37 | }, | |
38 | 'playlist': [{ | |
39 | 'info_dict': { | |
40 | 'id': 'mVmBL8B-In0', | |
41 | 'ext': 'mp4', | |
e793338c YCH |
42 | 'title': 're:Munchkin the Teddy Bear gets her exercise', |
43 | 'description': 'md5:28faab95cda6e361bcff06ec12fc21d8', | |
4207558e PH |
44 | 'upload_date': '20141124', |
45 | 'uploader_id': 'CindysMunchkin', | |
6e99868e | 46 | 'uploader': 're:^Munchkin the', |
4207558e PH |
47 | }, |
48 | }] | |
e793338c YCH |
49 | }, { |
50 | 'url': 'http://www.buzzfeed.com/craigsilverman/the-most-adorable-crash-landing-ever#.eq7pX0BAmK', | |
51 | 'info_dict': { | |
52 | 'id': 'the-most-adorable-crash-landing-ever', | |
53 | 'title': 'Watch This Baby Goose Make The Most Adorable Crash Landing', | |
54 | 'description': 'This gosling knows how to stick a landing.', | |
55 | }, | |
56 | 'playlist': [{ | |
57 | 'md5': '763ca415512f91ca62e4621086900a23', | |
58 | 'info_dict': { | |
59 | 'id': '971793786185728', | |
60 | 'ext': 'mp4', | |
61 | 'title': 'We set up crash pads so that the goslings on our roof would have a safe landi...', | |
62 | 'uploader': 'Calgary Outdoor Centre-University of Calgary', | |
63 | }, | |
64 | }], | |
65 | 'add_ie': ['Facebook'], | |
4207558e | 66 | }] |
e232f787 PH |
67 | |
68 | def _real_extract(self, url): | |
69 | playlist_id = self._match_id(url) | |
70 | webpage = self._download_webpage(url, playlist_id) | |
71 | ||
72 | all_buckets = re.findall( | |
4207558e | 73 | r'(?s)<div class="video-embed[^"]*"..*?rel:bf_bucket_data=\'([^\']+)\'', |
e232f787 | 74 | webpage) |
4207558e | 75 | |
e232f787 PH |
76 | entries = [] |
77 | for bd_json in all_buckets: | |
78 | bd = json.loads(bd_json) | |
4207558e PH |
79 | video = bd.get('video') or bd.get('progload_video') |
80 | if not video: | |
e232f787 | 81 | continue |
4207558e | 82 | entries.append(self.url_result(video['url'])) |
e232f787 | 83 | |
bfd973ec | 84 | facebook_urls = FacebookIE._extract_embed_urls(url, webpage) |
0646e34c S |
85 | entries.extend([ |
86 | self.url_result(facebook_url) | |
87 | for facebook_url in facebook_urls]) | |
e793338c | 88 | |
e232f787 PH |
89 | return { |
90 | '_type': 'playlist', | |
91 | 'id': playlist_id, | |
92 | 'title': self._og_search_title(webpage), | |
93 | 'description': self._og_search_description(webpage), | |
94 | 'entries': entries, | |
95 | } |