2017-01-03 22:51:08 +00:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
|
|
|
from ..utils import (
|
|
|
|
ExtractorError,
|
|
|
|
clean_html,
|
|
|
|
compat_str,
|
2017-05-14 08:04:42 +00:00
|
|
|
float_or_none,
|
2017-01-03 22:51:08 +00:00
|
|
|
int_or_none,
|
|
|
|
parse_iso8601,
|
|
|
|
try_get,
|
2017-05-14 08:04:42 +00:00
|
|
|
urljoin,
|
2017-01-03 22:51:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2017-05-14 08:04:42 +00:00
|
|
|
class BeamProBaseIE(InfoExtractor):
|
2017-05-27 22:39:28 +00:00
|
|
|
_API_BASE = 'https://mixer.com/api/v1'
|
2017-05-14 08:04:42 +00:00
|
|
|
_RATINGS = {'family': 0, 'teen': 13, '18+': 18}
|
|
|
|
|
|
|
|
def _extract_channel_info(self, chan):
|
|
|
|
user_id = chan.get('userId') or try_get(chan, lambda x: x['user']['id'])
|
|
|
|
return {
|
|
|
|
'uploader': chan.get('token') or try_get(
|
|
|
|
chan, lambda x: x['user']['username'], compat_str),
|
|
|
|
'uploader_id': compat_str(user_id) if user_id else None,
|
|
|
|
'age_limit': self._RATINGS.get(chan.get('audience')),
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class BeamProLiveIE(BeamProBaseIE):
|
2017-05-27 22:39:28 +00:00
|
|
|
IE_NAME = 'Mixer:live'
|
|
|
|
_VALID_URL = r'https?://(?:\w+\.)?(?:beam\.pro|mixer\.com)/(?P<id>[^/?#&]+)'
|
2017-01-03 22:51:08 +00:00
|
|
|
_TEST = {
|
2017-05-27 22:39:28 +00:00
|
|
|
'url': 'http://mixer.com/niterhayven',
|
2017-01-03 22:51:08 +00:00
|
|
|
'info_dict': {
|
|
|
|
'id': '261562',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Introducing The Witcher 3 // The Grind Starts Now!',
|
2017-01-14 23:07:35 +00:00
|
|
|
'description': 'md5:0b161ac080f15fe05d18a07adb44a74d',
|
2017-01-03 22:51:08 +00:00
|
|
|
'thumbnail': r're:https://.*\.jpg$',
|
2017-01-14 23:07:35 +00:00
|
|
|
'timestamp': 1483477281,
|
2017-01-03 22:51:08 +00:00
|
|
|
'upload_date': '20170103',
|
2017-01-14 23:07:35 +00:00
|
|
|
'uploader': 'niterhayven',
|
|
|
|
'uploader_id': '373396',
|
|
|
|
'age_limit': 18,
|
2017-01-03 22:51:08 +00:00
|
|
|
'is_live': True,
|
2017-01-14 23:07:35 +00:00
|
|
|
'view_count': int,
|
2017-01-03 22:51:08 +00:00
|
|
|
},
|
|
|
|
'skip': 'niterhayven is offline',
|
|
|
|
'params': {
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-05-27 22:39:28 +00:00
|
|
|
_MANIFEST_URL_TEMPLATE = '%s/channels/%%s/manifest.%%s' % BeamProBaseIE._API_BASE
|
|
|
|
|
2017-05-14 08:04:42 +00:00
|
|
|
@classmethod
|
|
|
|
def suitable(cls, url):
|
|
|
|
return False if BeamProVodIE.suitable(url) else super(BeamProLiveIE, cls).suitable(url)
|
|
|
|
|
2017-01-03 22:51:08 +00:00
|
|
|
def _real_extract(self, url):
|
2017-01-14 23:07:35 +00:00
|
|
|
channel_name = self._match_id(url)
|
2017-01-03 22:51:08 +00:00
|
|
|
|
2017-01-14 23:07:35 +00:00
|
|
|
chan = self._download_json(
|
2017-05-27 22:39:28 +00:00
|
|
|
'%s/channels/%s' % (self._API_BASE, channel_name), channel_name)
|
2017-01-03 22:51:08 +00:00
|
|
|
|
2017-01-14 23:07:35 +00:00
|
|
|
if chan.get('online') is False:
|
|
|
|
raise ExtractorError(
|
|
|
|
'{0} is offline'.format(channel_name), expected=True)
|
2017-01-03 22:51:08 +00:00
|
|
|
|
2017-01-14 23:07:35 +00:00
|
|
|
channel_id = chan['id']
|
2017-01-03 22:51:08 +00:00
|
|
|
|
2017-05-27 22:39:28 +00:00
|
|
|
def manifest_url(kind):
|
|
|