1 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from ..compat import compat_urllib_request
8 from ..utils import ExtractorError
11 class BambuserIE(InfoExtractor):
13 _VALID_URL = r'https?://bambuser\.com/v/(?P<id>\d+)'
14 _API_KEY = '005f64509e19a868399060af746a00aa'
17 'url': 'http://bambuser.com/v/4050584',
18 # MD5 seems to be flaky, see https://travis-ci.org/rg3/youtube-dl/jobs/14051016#L388
19 # 'md5': 'fba8f7693e48fd4e8641b3fd5539a641',
23 'title': 'Education engineering days - lightning talks',
25 'uploader': 'pixelversity',
26 'uploader_id': '344706',
29 # It doesn't respect the 'Range' header, it would download the whole video
30 # caused the travis builds to fail: https://travis-ci.org/rg3/youtube-dl/jobs/14493845#L59
31 'skip_download': True,
35 def _real_extract(self, url):
36 video_id = self._match_id(url)
38 info = self._download_json(
39 'http://player-c.api.bambuser.com/getVideo.json?api_key=%s&vid=%s'
40 % (self._API_KEY, video_id), video_id)
42 error = info.get('error')
45 '%s returned error: %s' % (self.IE_NAME, error), expected=True)
47 result = info['result']
51 'title': result['title'],
53 'thumbnail': result.get('preview'),
54 'duration': int(result['length']),
55 'view_count': int(result['views_total']),
56 'uploader': result['username'],
57 'uploader_id': result['owner']['uid'],
61 class BambuserChannelIE(InfoExtractor):
62 IE_NAME = 'bambuser:channel'
63 _VALID_URL = r'https?://bambuser\.com/channel/(?P<user>.*?)(?:/|#|\?|$)'
64 # The maximum number we can get with each request
67 'url': 'http://bambuser.com/channel/pixelversity',
69 'title': 'pixelversity',
71 'playlist_mincount': 60,
74 def _real_extract(self, url):
75 mobj = re.match(self._VALID_URL, url)
76 user = mobj.group('user')
79 for i in itertools.count(1):
81 'http://bambuser.com/xhr-api/index.php?username={user}'
82 '&sort=created&access_mode=0%2C1%2C2&limit={count}'
83 '&method=broadcast&format=json&vid_older_than={last}'
84 ).format(user=user, count=self._STEP, last=last_id)
85 req = compat_urllib_request.Request(req_url)
86 # Without setting this header, we wouldn't get any result
87 req.add_header('Referer', 'http://bambuser.com/channel/%s' % user)
88 data = self._download_json(
89 req, user, 'Downloading page %d' % i)
90 results = data['result']
93 last_id = results[-1]['vid']
94 urls.extend(self.url_result(v['page'], 'Bambuser') for v in results)