Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[beampro] Added support for Mixer clips #23061

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 69 additions & 1 deletion youtube_dl/extractor/beampro.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class BeamProLiveIE(BeamProBaseIE):

@classmethod
def suitable(cls, url):
return False if BeamProVodIE.suitable(url) else super(BeamProLiveIE, cls).suitable(url)
return False if BeamProVodIE.suitable(url) or BeamProClipIE.suitable(url) else super(BeamProLiveIE, cls).suitable(url)

def _real_extract(self, url):
channel_name = self._match_id(url)
Expand Down Expand Up @@ -192,3 +192,71 @@ def _real_extract(self, url):
info.update(self._extract_channel_info(vod_info.get('channel') or {}))

return info


class BeamProClipIE(BeamProBaseIE):
IE_NAME = 'Mixer:clip'
_VALID_URL = r'https?://(?:\w+\.)?(?:beam\.pro|mixer\.com)/[^/?#&]+\?.*?\bclip=(?P<id>[^?#&]+)'
_TEST = {
'url': 'https://mixer.com/PermaNoob?clip=DB1mDsthm0eTtpsXv35vJw',
'md5': '581390e34c073251514bc825fded9d6f',
'info_dict': {
'id': 'DB1mDsthm0eTtpsXv35vJw',
'ext': 'mp4',
'title': 'Morning Shenanigans: Come Hang Out with Us!',
'duration': 32.0,
'thumbnail': r're:https://.*big\.jpg$',
'timestamp': 1573233791,
'upload_date': '20191108',
'view_count': int,
}
}

@staticmethod
def _extract_format(clip, clip_type):
if not clip.get('uri'):
return []

if clip_type == 'HlsStreaming':
protocol = 'm3u8_native'
else:
assert False

format_id = [clip_type]

return [{
'url': clip.get('uri'),
'format_id': '-'.join(format_id),
'ext': 'mp4',
'protocol': protocol
}]

def _real_extract(self, url):
clip_id = self._match_id(url)

clip_info = self._download_json(
'%s/clips/%s' % (self._API_BASE, clip_id), clip_id)

formats = []
thumbnail_url = None

for locator in clip_info['contentLocators']:
locator_type = locator.get('locatorType')
if locator_type == 'HlsStreaming':
formats.extend(self._extract_format(locator, locator_type))
elif locator_type == 'Thumbnail_Large':
thumbnail_url = locator.get('uri')

self._sort_formats(formats)

info = {
'id': clip_id,
'title': clip_info.get('title') or clip_id,
'duration': float_or_none(clip_info.get('durationInSeconds')),
'thumbnail': thumbnail_url,
'timestamp': parse_iso8601(clip_info.get('uploadDate')),
'view_count': int_or_none(clip_info.get('viewCount')),
'formats': formats,
}

return info
1 change: 1 addition & 0 deletions youtube_dl/extractor/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
from .beampro import (
BeamProLiveIE,
BeamProVodIE,
BeamProClipIE,
)
from .beeg import BeegIE
from .behindkink import BehindKinkIE
Expand Down