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