]>
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 | |
8 | ||
9 | ||
10 | class BuzzFeedIE(InfoExtractor): | |
11 | _VALID_URL = r'https?://(?:www\.)?buzzfeed\.com/[^?#]*?/(?P<id>[^?#]+)' | |
4207558e | 12 | _TESTS = [{ |
e232f787 PH |
13 | 'url': 'http://www.buzzfeed.com/abagg/this-angry-ram-destroys-a-punching-bag-like-a-boss?utm_term=4ldqpia', |
14 | 'info_dict': { | |
15 | 'id': 'this-angry-ram-destroys-a-punching-bag-like-a-boss', | |
16 | 'title': 'This Angry Ram Destroys A Punching Bag Like A Boss', | |
17 | 'description': 'Rambro!', | |
18 | }, | |
19 | 'playlist': [{ | |
20 | 'info_dict': { | |
21 | 'id': 'aVCR29aE_OQ', | |
22 | 'ext': 'mp4', | |
23 | 'upload_date': '20141024', | |
24 | 'uploader_id': 'Buddhanz1', | |
25 | 'description': 'He likes to stay in shape with his heavy bag, he wont stop until its on the ground\n\nFollow Angry Ram on Facebook for regular updates -\nhttps://www.facebook.com/pages/Angry-Ram/1436897249899558?ref=hl', | |
26 | 'uploader': 'Buddhanz', | |
27 | 'title': 'Angry Ram destroys a punching bag', | |
28 | } | |
29 | }] | |
4207558e PH |
30 | }, { |
31 | 'url': 'http://www.buzzfeed.com/sheridanwatson/look-at-this-cute-dog-omg?utm_term=4ldqpia', | |
32 | 'params': { | |
33 | 'skip_download': True, # Got enough YouTube download tests | |
34 | }, | |
35 | 'info_dict': { | |
6e99868e | 36 | 'id': 'look-at-this-cute-dog-omg', |
db6e6250 | 37 | 'description': 're:Munchkin the Teddy Bear is back ?!', |
4207558e PH |
38 | 'title': 'You Need To Stop What You\'re Doing And Watching This Dog Walk On A Treadmill', |
39 | }, | |
40 | 'playlist': [{ | |
41 | 'info_dict': { | |
42 | 'id': 'mVmBL8B-In0', | |
43 | 'ext': 'mp4', | |
44 | 'upload_date': '20141124', | |
45 | 'uploader_id': 'CindysMunchkin', | |
6e99868e PH |
46 | 'description': 're:© 2014 Munchkin the', |
47 | 'uploader': 're:^Munchkin the', | |
db6e6250 | 48 | 'title': 're:Munchkin the Teddy Bear gets her exercise', |
4207558e PH |
49 | }, |
50 | }] | |
51 | }] | |
e232f787 PH |
52 | |
53 | def _real_extract(self, url): | |
54 | playlist_id = self._match_id(url) | |
55 | webpage = self._download_webpage(url, playlist_id) | |
56 | ||
57 | all_buckets = re.findall( | |
4207558e | 58 | r'(?s)<div class="video-embed[^"]*"..*?rel:bf_bucket_data=\'([^\']+)\'', |
e232f787 | 59 | webpage) |
4207558e | 60 | |
e232f787 PH |
61 | entries = [] |
62 | for bd_json in all_buckets: | |
63 | bd = json.loads(bd_json) | |
4207558e PH |
64 | video = bd.get('video') or bd.get('progload_video') |
65 | if not video: | |
e232f787 | 66 | continue |
4207558e | 67 | entries.append(self.url_result(video['url'])) |
e232f787 PH |
68 | |
69 | return { | |
70 | '_type': 'playlist', | |
71 | 'id': playlist_id, | |
72 | 'title': self._og_search_title(webpage), | |
73 | 'description': self._og_search_description(webpage), | |
74 | 'entries': entries, | |
75 | } |