5 from .common import InfoExtractor
11 class BambuserIE(InfoExtractor):
13 _VALID_URL = r'https?://bambuser\.com/v/(?P<id>\d+)'
14 _API_KEY = '005f64509e19a868399060af746a00aa'
17 u'url': u'http://bambuser.com/v/4050584',
18 # MD5 seems to be flaky, see https://travis-ci.org/rg3/youtube-dl/jobs/14051016#L388
19 #u'md5': u'fba8f7693e48fd4e8641b3fd5539a641',
23 u'title': u'Education engineering days - lightning talks',
25 u'uploader': u'pixelversity',
26 u'uploader_id': u'344706',
30 def _real_extract(self, url):
31 mobj = re.match(self._VALID_URL, url)
32 video_id = mobj.group('id')
33 info_url = ('http://player-c.api.bambuser.com/getVideo.json?'
34 '&api_key=%s&vid=%s' % (self._API_KEY, video_id))
35 info_json = self._download_webpage(info_url, video_id)
36 info = json.loads(info_json)['result']
40 'title': info['title'],
42 'thumbnail': info.get('preview'),
43 'duration': int(info['length']),
44 'view_count': int(info['views_total']),
45 'uploader': info['username'],
46 'uploader_id': info['uid'],
50 class BambuserChannelIE(InfoExtractor):
51 IE_NAME = u'bambuser:channel'
52 _VALID_URL = r'http://bambuser.com/channel/(?P<user>.*?)(?:/|#|\?|$)'
53 # The maximum number we can get with each request
56 def _real_extract(self, url):
57 mobj = re.match(self._VALID_URL, url)
58 user = mobj.group('user')
61 for i in itertools.count(1):
62 req_url = ('http://bambuser.com/xhr-api/index.php?username={user}'
63 '&sort=created&access_mode=0%2C1%2C2&limit={count}'
64 '&method=broadcast&format=json&vid_older_than={last}'
65 ).format(user=user, count=self._STEP, last=last_id)
66 req = compat_urllib_request.Request(req_url)
67 # Without setting this header, we wouldn't get any result
68 req.add_header('Referer', 'http://bambuser.com/channel/%s' % user)
69 info_json = self._download_webpage(req, user,
70 u'Downloading page %d' % i)
71 results = json.loads(info_json)['result']
74 last_id = results[-1]['vid']
75 urls.extend(self.url_result(v['page'], 'Bambuser') for v in results)