]>
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 u
'md5': u
'fba8f7693e48fd4e8641b3fd5539a641',
22 u
'title': u
'Education engineering days - lightning talks',
24 u
'uploader': u
'pixelversity',
25 u
'uploader_id': u
'344706',
29 def _real_extract(self
, url
):
30 mobj
= re
.match(self
._VALID
_URL
, url
)
31 video_id
= mobj
.group('id')
32 info_url
= ('http://player-c.api.bambuser.com/getVideo.json?'
33 '&api_key=%s&vid=%s' % (self
._API
_KEY
, video_id
))
34 info_json
= self
._download
_webpage
(info_url
, video_id
)
35 info
= json
.loads(info_json
)['result']
39 'title': info
['title'],
41 'thumbnail': info
.get('preview'),
42 'duration': int(info
['length']),
43 'view_count': int(info
['views_total']),
44 'uploader': info
['username'],
45 'uploader_id': info
['uid'],
49 class BambuserChannelIE(InfoExtractor
):
50 IE_NAME
= u
'bambuser:channel'
51 _VALID_URL
= r
'http://bambuser.com/channel/(?P<user>.*?)(?:/|#|\?|$)'
52 # The maximum number we can get with each request
55 def _real_extract(self
, url
):
56 mobj
= re
.match(self
._VALID
_URL
, url
)
57 user
= mobj
.group('user')
60 for i
in itertools
.count(1):
61 req_url
= ('http://bambuser.com/xhr-api/index.php?username={user}'
62 '&sort=created&access_mode=0%2C1%2C2&limit={count}'
63 '&method=broadcast&format=json&vid_older_than={last}'
64 ).format(user
=user
, count
=self
._STEP
, last
=last_id
)
65 req
= compat_urllib_request
.Request(req_url
)
66 # Without setting this header, we wouldn't get any result
67 req
.add_header('Referer', 'http://bambuser.com/channel/%s' % user
)
68 info_json
= self
._download
_webpage
(req
, user
,
69 u
'Downloading page %d' % i
)
70 results
= json
.loads(info_json
)['result']
73 last_id
= results
[-1]['vid']
74 urls
.extend(self
.url_result(v
['page'], 'Bambuser') for v
in results
)