mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-21 20:46:36 -05:00
[LBRY] Support livestreams (#2062)
Closes #2054 Authored by: Ashish0804, pukkandan
This commit is contained in:
parent
205a0654c0
commit
c25de59cf7
1 changed files with 25 additions and 15 deletions
|
@ -184,28 +184,38 @@ def _real_extract(self, url):
|
||||||
display_id = compat_urllib_parse_unquote(display_id)
|
display_id = compat_urllib_parse_unquote(display_id)
|
||||||
uri = 'lbry://' + display_id
|
uri = 'lbry://' + display_id
|
||||||
result = self._resolve_url(uri, display_id, 'stream')
|
result = self._resolve_url(uri, display_id, 'stream')
|
||||||
result_value = result['value']
|
if result['value'].get('stream_type') in self._SUPPORTED_STREAM_TYPES:
|
||||||
if result_value.get('stream_type') not in self._SUPPORTED_STREAM_TYPES:
|
claim_id, is_live, headers = result['claim_id'], False, None
|
||||||
raise ExtractorError('Unsupported URL', expected=True)
|
|
||||||
claim_id = result['claim_id']
|
|
||||||
title = result_value['title']
|
|
||||||
streaming_url = self._call_api_proxy(
|
streaming_url = self._call_api_proxy(
|
||||||
'get', claim_id, {'uri': uri}, 'streaming url')['streaming_url']
|
'get', claim_id, {'uri': uri}, 'streaming url')['streaming_url']
|
||||||
|
final_url = self._request_webpage(
|
||||||
|
streaming_url, display_id, note='Downloading streaming redirect url info').geturl()
|
||||||
|
elif result.get('value_type') == 'stream':
|
||||||
|
claim_id, is_live = result['signing_channel']['claim_id'], True
|
||||||
|
headers = {'referer': 'https://player.odysee.live/'}
|
||||||
|
live_data = self._download_json(
|
||||||
|
f'https://api.live.odysee.com/v1/odysee/live/{claim_id}', claim_id,
|
||||||
|
note='Downloading livestream JSON metadata')['data']
|
||||||
|
if not live_data['live']:
|
||||||
|
raise ExtractorError('This stream is not live', expected=True)
|
||||||
|
streaming_url = final_url = live_data['url']
|
||||||
|
else:
|
||||||
|
raise ExtractorError('Unsupported URL', expected=True)
|
||||||
|
|
||||||
info = self._parse_stream(result, url)
|
info = self._parse_stream(result, url)
|
||||||
urlh = self._request_webpage(
|
if determine_ext(final_url) == 'm3u8':
|
||||||
streaming_url, display_id, note='Downloading streaming redirect url info')
|
|
||||||
if determine_ext(urlh.geturl()) == 'm3u8':
|
|
||||||
info['formats'] = self._extract_m3u8_formats(
|
info['formats'] = self._extract_m3u8_formats(
|
||||||
urlh.geturl(), display_id, 'mp4', entry_protocol='m3u8_native',
|
final_url, display_id, 'mp4', 'm3u8_native', m3u8_id='hls', live=is_live, headers=headers)
|
||||||
m3u8_id='hls')
|
|
||||||
self._sort_formats(info['formats'])
|
self._sort_formats(info['formats'])
|
||||||
else:
|
else:
|
||||||
info['url'] = streaming_url
|
info['url'] = streaming_url
|
||||||
info.update({
|
return {
|
||||||
|
**info,
|
||||||
'id': claim_id,
|
'id': claim_id,
|
||||||
'title': title,
|
'title': result['value']['title'],
|
||||||
})
|
'is_live': is_live,
|
||||||
return info
|
'http_headers': headers,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class LBRYChannelIE(LBRYBaseIE):
|
class LBRYChannelIE(LBRYBaseIE):
|
||||||
|
|
Loading…
Reference in a new issue