]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/bambuser.py
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',
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 u
'skip_download': True,
35 def _real_extract(self
, url
):
36 mobj
= re
.match(self
._VALID
_URL
, url
)
37 video_id
= mobj
.group('id')
38 info_url
= ('http://player-c.api.bambuser.com/getVideo.json?'
39 '&api_key=%s&vid=%s' % (self
._API
_KEY
, video_id
))
40 info_json
= self
._download
_webpage
(info_url
, video_id
)
41 info
= json
.loads(info_json
)['result']
45 'title': info
['title'],
47 'thumbnail': info
.get('preview'),
48 'duration': int(info
['length']),
49 'view_count': int(info
['views_total']),
50 'uploader': info
['username'],
51 'uploader_id': info
['uid'],
55 class BambuserChannelIE(InfoExtractor
):
56 IE_NAME
= u
'bambuser:channel'
57 _VALID_URL
= r
'http://bambuser.com/channel/(?P<user>.*?)(?:/|#|\?|$)'
58 # The maximum number we can get with each request
61 def _real_extract(self
, url
):
62 mobj
= re
.match(self
._VALID
_URL
, url
)
63 user
= mobj
.group('user')
66 for i
in itertools
.count(1):
67 req_url
= ('http://bambuser.com/xhr-api/index.php?username={user}'
68 '&sort=created&access_mode=0%2C1%2C2&limit={count}'
69 '&method=broadcast&format=json&vid_older_than={last}'
70 ).format(user
=user
, count
=self
._STEP
, last
=last_id
)
71 req
= compat_urllib_request
.Request(req_url
)
72 # Without setting this header, we wouldn't get any result
73 req
.add_header('Referer', 'http://bambuser.com/channel/%s' % user
)
74 info_json
= self
._download
_webpage
(req
, user
,
75 u
'Downloading page %d' % i
)
76 results
= json
.loads(info_json
)['result']
79 last_id
= results
[-1]['vid']
80 urls
.extend(self
.url_result(v
['page'], 'Bambuser') for v
in results
)