]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/bambuser.py
633c57553d9a9e769f726a664e08061217763ced
1 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_str
17 class BambuserIE(InfoExtractor
):
19 _VALID_URL
= r
'https?://bambuser\.com/v/(?P<id>\d+)'
20 _API_KEY
= '005f64509e19a868399060af746a00aa'
21 _LOGIN_URL
= 'https://bambuser.com/user'
22 _NETRC_MACHINE
= 'bambuser'
25 'url': 'http://bambuser.com/v/4050584',
26 # MD5 seems to be flaky, see https://travis-ci.org/rg3/youtube-dl/jobs/14051016#L388
27 # 'md5': 'fba8f7693e48fd4e8641b3fd5539a641',
31 'title': 'Education engineering days - lightning talks',
33 'uploader': 'pixelversity',
34 'uploader_id': '344706',
35 'timestamp': 1382976692,
36 'upload_date': '20131028',
40 # It doesn't respect the 'Range' header, it would download the whole video
41 # caused the travis builds to fail: https://travis-ci.org/rg3/youtube-dl/jobs/14493845#L59
42 'skip_download': True,
47 (username
, password
) = self
._get
_login
_info
()
52 'form_id': 'user_login',
58 request
= sanitized_Request(
59 self
._LOGIN
_URL
, urlencode_postdata(login_form
))
60 request
.add_header('Referer', self
._LOGIN
_URL
)
61 response
= self
._download
_webpage
(
62 request
, None, 'Logging in')
64 login_error
= self
._html
_search
_regex
(
65 r
'(?s)<div class="messages error">(.+?)</div>',
66 response
, 'login error', default
=None)
69 'Unable to login: %s' % login_error
, expected
=True)
71 def _real_initialize(self
):
74 def _real_extract(self
, url
):
75 video_id
= self
._match
_id
(url
)
77 info
= self
._download
_json
(
78 'http://player-c.api.bambuser.com/getVideo.json?api_key=%s&vid=%s'
79 % (self
._API
_KEY
, video_id
), video_id
)
81 error
= info
.get('error')
84 '%s returned error: %s' % (self
.IE_NAME
, error
), expected
=True)
86 result
= info
['result']
90 'title': result
['title'],
92 'thumbnail': result
.get('preview'),
93 'duration': int_or_none(result
.get('length')),
94 'uploader': result
.get('username'),
95 'uploader_id': compat_str(result
.get('owner', {}).get('uid')),
96 'timestamp': int_or_none(result
.get('created')),
97 'fps': float_or_none(result
.get('framerate')),
98 'view_count': int_or_none(result
.get('views_total')),
99 'comment_count': int_or_none(result
.get('comment_count')),
103 class BambuserChannelIE(InfoExtractor
):
104 IE_NAME
= 'bambuser:channel'
105 _VALID_URL
= r
'https?://bambuser\.com/channel/(?P<user>.*?)(?:/|#|\?|$)'
106 # The maximum number we can get with each request
109 'url': 'http://bambuser.com/channel/pixelversity',
111 'title': 'pixelversity',
113 'playlist_mincount': 60,
116 def _real_extract(self
, url
):
117 mobj
= re
.match(self
._VALID
_URL
, url
)
118 user
= mobj
.group('user')
121 for i
in itertools
.count(1):
123 'http://bambuser.com/xhr-api/index.php?username={user}'
124 '&sort=created&access_mode=0%2C1%2C2&limit={count}'
125 '&method=broadcast&format=json&vid_older_than={last}'
126 ).format(user
=user
, count
=self
._STEP
, last
=last_id
)
127 req
= sanitized_Request(req_url
)
128 # Without setting this header, we wouldn't get any result
129 req
.add_header('Referer', 'http://bambuser.com/channel/%s' % user
)
130 data
= self
._download
_json
(
131 req
, user
, 'Downloading page %d' % i
)
132 results
= data
['result']
135 last_id
= results
[-1]['vid']
136 urls
.extend(self
.url_result(v
['page'], 'Bambuser') for v
in results
)