|
|
@ -22,10 +22,11 @@ from ..utils import (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LBRYBaseIE(InfoExtractor):
|
|
|
|
class LBRYBaseIE(InfoExtractor):
|
|
|
|
_BASE_URL_REGEX = r'(?:https?://(?:www\.)?(?:lbry\.tv|odysee\.com)/|lbry://)'
|
|
|
|
_BASE_URL_REGEX = r'(?x)(?:https?://(?:www\.)?(?:lbry\.tv|odysee\.com)/|lbry://)'
|
|
|
|
_CLAIM_ID_REGEX = r'[0-9a-f]{1,40}'
|
|
|
|
_CLAIM_ID_REGEX = r'[0-9a-f]{1,40}'
|
|
|
|
_OPT_CLAIM_ID = '[^:/?#&]+(?:[:#]%s)?' % _CLAIM_ID_REGEX
|
|
|
|
_OPT_CLAIM_ID = '[^$@:/?#&]+(?:[:#]%s)?' % _CLAIM_ID_REGEX
|
|
|
|
_SUPPORTED_STREAM_TYPES = ['video', 'audio']
|
|
|
|
_SUPPORTED_STREAM_TYPES = ['video', 'audio']
|
|
|
|
|
|
|
|
_PAGE_SIZE = 50
|
|
|
|
|
|
|
|
|
|
|
|
def _call_api_proxy(self, method, display_id, params, resource):
|
|
|
|
def _call_api_proxy(self, method, display_id, params, resource):
|
|
|
|
headers = {'Content-Type': 'application/json-rpc'}
|
|
|
|
headers = {'Content-Type': 'application/json-rpc'}
|
|
|
@ -77,10 +78,70 @@ class LBRYBaseIE(InfoExtractor):
|
|
|
|
|
|
|
|
|
|
|
|
return info
|
|
|
|
return info
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _fetch_page(self, display_id, url, params, page):
|
|
|
|
|
|
|
|
page += 1
|
|
|
|
|
|
|
|
page_params = {
|
|
|
|
|
|
|
|
'no_totals': True,
|
|
|
|
|
|
|
|
'page': page,
|
|
|
|
|
|
|
|
'page_size': self._PAGE_SIZE,
|
|
|
|
|
|
|
|
**params,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
result = self._call_api_proxy(
|
|
|
|
|
|
|
|
'claim_search', display_id, page_params, f'page {page}')
|
|
|
|
|
|
|
|
for item in traverse_obj(result, ('items', lambda _, v: v['name'] and v['claim_id'])):
|
|
|
|
|
|
|
|
yield {
|
|
|
|
|
|
|
|
**self._parse_stream(item, url),
|
|
|
|
|
|
|
|
'_type': 'url',
|
|
|
|
|
|
|
|
'id': item['claim_id'],
|
|
|
|
|
|
|
|
'url': self._permanent_url(url, item['name'], item['claim_id']),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _playlist_entries(self, url, display_id, claim_param, metadata):
|
|
|
|
|
|
|
|
qs = parse_qs(url)
|
|
|
|
|
|
|
|
content = qs.get('content', [None])[0]
|
|
|
|
|
|
|
|
params = {
|
|
|
|
|
|
|
|
'fee_amount': qs.get('fee_amount', ['>=0'])[0],
|
|
|
|
|
|
|
|
'order_by': {
|
|
|
|
|
|
|
|
'new': ['release_time'],
|
|
|
|
|
|
|
|
'top': ['effective_amount'],
|
|
|
|
|
|
|
|
'trending': ['trending_group', 'trending_mixed'],
|
|
|
|
|
|
|
|
}[qs.get('order', ['new'])[0]],
|
|
|
|
|
|
|
|
'claim_type': 'stream',
|
|
|
|
|
|
|
|
'stream_types': [content] if content in ['audio', 'video'] else self._SUPPORTED_STREAM_TYPES,
|
|
|
|
|
|
|
|
**claim_param,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
duration = qs.get('duration', [None])[0]
|
|
|
|
|
|
|
|
if duration:
|
|
|
|
|
|
|
|
params['duration'] = {
|
|
|
|
|
|
|
|
'long': '>=1200',
|
|
|
|
|
|
|
|
'short': '<=240',
|
|
|
|
|
|
|
|
}[duration]
|
|
|
|
|
|
|
|
language = qs.get('language', ['all'])[0]
|
|
|
|
|
|
|
|
if language != 'all':
|
|
|
|
|
|
|
|
languages = [language]
|
|
|
|
|
|
|
|
if language == 'en':
|
|
|
|
|
|
|
|
languages.append('none')
|
|
|
|
|
|
|
|
params['any_languages'] = languages
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
entries = OnDemandPagedList(
|
|
|
|
|
|
|
|
functools.partial(self._fetch_page, display_id, url, params),
|
|
|
|
|
|
|
|
self._PAGE_SIZE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return self.playlist_result(
|
|
|
|
|
|
|
|
entries, display_id, **traverse_obj(metadata, ('value', {
|
|
|
|
|
|
|
|
'title': 'title',
|
|
|
|
|
|
|
|
'description': 'description',
|
|
|
|
|
|
|
|
})))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LBRYIE(LBRYBaseIE):
|
|
|
|
class LBRYIE(LBRYBaseIE):
|
|
|
|
IE_NAME = 'lbry'
|
|
|
|
IE_NAME = 'lbry'
|
|
|
|
_VALID_URL = LBRYBaseIE._BASE_URL_REGEX + r'(?P<id>\$/[^/]+/[^/]+/{1}|@{0}/{0}|(?!@){0})'.format(LBRYBaseIE._OPT_CLAIM_ID, LBRYBaseIE._CLAIM_ID_REGEX)
|
|
|
|
_VALID_URL = LBRYBaseIE._BASE_URL_REGEX + rf'''
|
|
|
|
|
|
|
|
(?:\$/(?:download|embed)/)?
|
|
|
|
|
|
|
|
(?P<id>
|
|
|
|
|
|
|
|
[^$@:/?#]+/{LBRYBaseIE._CLAIM_ID_REGEX}
|
|
|
|
|
|
|
|
|(?:@{LBRYBaseIE._OPT_CLAIM_ID}/)?{LBRYBaseIE._OPT_CLAIM_ID}
|
|
|
|
|
|
|
|
)'''
|
|
|
|
_TESTS = [{
|
|
|
|
_TESTS = [{
|
|
|
|
# Video
|
|
|
|
# Video
|
|
|
|
'url': 'https://lbry.tv/@Mantega:1/First-day-LBRY:1',
|
|
|
|
'url': 'https://lbry.tv/@Mantega:1/First-day-LBRY:1',
|
|
|
@ -149,7 +210,7 @@ class LBRYIE(LBRYBaseIE):
|
|
|
|
'channel': 'Gardening In Canada',
|
|
|
|
'channel': 'Gardening In Canada',
|
|
|
|
'channel_id': 'b8be0e93b423dad221abe29545fbe8ec36e806bc',
|
|
|
|
'channel_id': 'b8be0e93b423dad221abe29545fbe8ec36e806bc',
|
|
|
|
'channel_url': 'https://odysee.com/@gardeningincanada:b8be0e93b423dad221abe29545fbe8ec36e806bc',
|
|
|
|
'channel_url': 'https://odysee.com/@gardeningincanada:b8be0e93b423dad221abe29545fbe8ec36e806bc',
|
|
|
|
'formats': 'mincount:3',
|
|
|
|
'formats': 'mincount:3', # FIXME
|
|
|
|
'thumbnail': 'https://thumbnails.lbry.com/AgHSc_HzrrE',
|
|
|
|
'thumbnail': 'https://thumbnails.lbry.com/AgHSc_HzrrE',
|
|
|
|
'license': 'Copyrighted (contact publisher)',
|
|
|
|
'license': 'Copyrighted (contact publisher)',
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -184,12 +245,12 @@ class LBRYIE(LBRYBaseIE):
|
|
|
|
'id': '41fbfe805eb73c8d3012c0c49faa0f563274f634',
|
|
|
|
'id': '41fbfe805eb73c8d3012c0c49faa0f563274f634',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Biotechnological Invasion of Skin (April 2023)',
|
|
|
|
'title': 'Biotechnological Invasion of Skin (April 2023)',
|
|
|
|
'description': 'md5:709a2f4c07bd8891cda3a7cc2d6fcf5c',
|
|
|
|
'description': 'md5:fe28689db2cb7ba3436d819ac3ffc378',
|
|
|
|
'channel': 'Wicked Truths',
|
|
|
|
'channel': 'Wicked Truths',
|
|
|
|
'channel_id': '23d2bbf856b0ceed5b1d7c5960bcc72da5a20cb0',
|
|
|
|
'channel_id': '23d2bbf856b0ceed5b1d7c5960bcc72da5a20cb0',
|
|
|
|
'channel_url': 'https://odysee.com/@wickedtruths:23d2bbf856b0ceed5b1d7c5960bcc72da5a20cb0',
|
|
|
|
'channel_url': 'https://odysee.com/@wickedtruths:23d2bbf856b0ceed5b1d7c5960bcc72da5a20cb0',
|
|
|
|
'timestamp': 1685790036,
|
|
|
|
'timestamp': 1695114347,
|
|
|
|
'upload_date': '20230603',
|
|
|
|
'upload_date': '20230919',
|
|
|
|
'release_timestamp': 1685617473,
|
|
|
|
'release_timestamp': 1685617473,
|
|
|
|
'release_date': '20230601',
|
|
|
|
'release_date': '20230601',
|
|
|
|
'duration': 1063,
|
|
|
|
'duration': 1063,
|
|
|
@ -229,10 +290,10 @@ class LBRYIE(LBRYBaseIE):
|
|
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
def _real_extract(self, url):
|
|
|
|
display_id = self._match_id(url)
|
|
|
|
display_id = self._match_id(url)
|
|
|
|
if display_id.startswith('$/'):
|
|
|
|
if display_id.startswith('@'):
|
|
|
|
display_id = display_id.split('/', 2)[-1].replace('/', ':')
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
display_id = display_id.replace(':', '#')
|
|
|
|
display_id = display_id.replace(':', '#')
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
display_id = display_id.replace('/', ':')
|
|
|
|
display_id = urllib.parse.unquote(display_id)
|
|
|
|
display_id = 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')
|
|
|
@ -299,7 +360,7 @@ class LBRYIE(LBRYBaseIE):
|
|
|
|
|
|
|
|
|
|
|
|
class LBRYChannelIE(LBRYBaseIE):
|
|
|
|
class LBRYChannelIE(LBRYBaseIE):
|
|
|
|
IE_NAME = 'lbry:channel'
|
|
|
|
IE_NAME = 'lbry:channel'
|
|
|
|
_VALID_URL = LBRYBaseIE._BASE_URL_REGEX + r'(?P<id>@%s)/?(?:[?&]|$)' % LBRYBaseIE._OPT_CLAIM_ID
|
|
|
|
_VALID_URL = LBRYBaseIE._BASE_URL_REGEX + rf'(?P<id>@{LBRYBaseIE._OPT_CLAIM_ID})/?(?:[?&]|$)'
|
|
|
|
_TESTS = [{
|
|
|
|
_TESTS = [{
|
|
|
|
'url': 'https://lbry.tv/@LBRYFoundation:0',
|
|
|
|
'url': 'https://lbry.tv/@LBRYFoundation:0',
|
|
|
|
'info_dict': {
|
|
|
|
'info_dict': {
|
|
|
@ -315,65 +376,50 @@ class LBRYChannelIE(LBRYBaseIE):
|
|
|
|
'url': 'lbry://@lbry#3f',
|
|
|
|
'url': 'lbry://@lbry#3f',
|
|
|
|
'only_matching': True,
|
|
|
|
'only_matching': True,
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
_PAGE_SIZE = 50
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _fetch_page(self, claim_id, url, params, page):
|
|
|
|
|
|
|
|
page += 1
|
|
|
|
|
|
|
|
page_params = {
|
|
|
|
|
|
|
|
'channel_ids': [claim_id],
|
|
|
|
|
|
|
|
'claim_type': 'stream',
|
|
|
|
|
|
|
|
'no_totals': True,
|
|
|
|
|
|
|
|
'page': page,
|
|
|
|
|
|
|
|
'page_size': self._PAGE_SIZE,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
page_params.update(params)
|
|
|
|
|
|
|
|
result = self._call_api_proxy(
|
|
|
|
|
|
|
|
'claim_search', claim_id, page_params, 'page %d' % page)
|
|
|
|
|
|
|
|
for item in (result.get('items') or []):
|
|
|
|
|
|
|
|
stream_claim_name = item.get('name')
|
|
|
|
|
|
|
|
stream_claim_id = item.get('claim_id')
|
|
|
|
|
|
|
|
if not (stream_claim_name and stream_claim_id):
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
yield {
|
|
|
|
|
|
|
|
**self._parse_stream(item, url),
|
|
|
|
|
|
|
|
'_type': 'url',
|
|
|
|
|
|
|
|
'id': stream_claim_id,
|
|
|
|
|
|
|
|
'url': self._permanent_url(url, stream_claim_name, stream_claim_id),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
def _real_extract(self, url):
|
|
|
|
display_id = self._match_id(url).replace(':', '#')
|
|
|
|
display_id = self._match_id(url).replace(':', '#')
|
|
|
|
result = self._resolve_url(
|
|
|
|
result = self._resolve_url(f'lbry://{display_id}', display_id, 'channel')
|
|
|
|
'lbry://' + display_id, display_id, 'channel')
|
|
|
|
|
|
|
|
claim_id = result['claim_id']
|
|
|
|
claim_id = result['claim_id']
|
|
|
|
qs = parse_qs(url)
|
|
|
|
|
|
|
|
content = qs.get('content', [None])[0]
|
|
|
|
return self._playlist_entries(url, claim_id, {'channel_ids': [claim_id]}, result)
|
|
|
|
params = {
|
|
|
|
|
|
|
|
'fee_amount': qs.get('fee_amount', ['>=0'])[0],
|
|
|
|
|
|
|
|
'order_by': {
|
|
|
|
class LBRYPlaylistIE(LBRYBaseIE):
|
|
|
|
'new': ['release_time'],
|
|
|
|
IE_NAME = 'lbry:playlist'
|
|
|
|
'top': ['effective_amount'],
|
|
|
|
_VALID_URL = LBRYBaseIE._BASE_URL_REGEX + r'\$/(?:play)?list/(?P<id>[0-9a-f-]+)'
|
|
|
|
'trending': ['trending_group', 'trending_mixed'],
|
|
|
|
_TESTS = [{
|
|
|
|
}[qs.get('order', ['new'])[0]],
|
|
|
|
'url': 'https://odysee.com/$/playlist/ffef782f27486f0ac138bde8777f72ebdd0548c2',
|
|
|
|
'stream_types': [content] if content in ['audio', 'video'] else self._SUPPORTED_STREAM_TYPES,
|
|
|
|
'info_dict': {
|
|
|
|
}
|
|
|
|
'id': 'ffef782f27486f0ac138bde8777f72ebdd0548c2',
|
|
|
|
duration = qs.get('duration', [None])[0]
|
|
|
|
'title': 'Théâtre Classique',
|
|
|
|
if duration:
|
|
|
|
'description': 'Théâtre Classique',
|
|
|
|
params['duration'] = {
|
|
|
|
},
|
|
|
|
'long': '>=1200',
|
|
|
|
'playlist_mincount': 4,
|
|
|
|
'short': '<=240',
|
|
|
|
}, {
|
|
|
|
}[duration]
|
|
|
|
'url': 'https://odysee.com/$/list/9c6658b3dd21e4f2a0602d523a13150e2b48b770',
|
|
|
|
language = qs.get('language', ['all'])[0]
|
|
|
|
'info_dict': {
|
|
|
|
if language != 'all':
|
|
|
|
'id': '9c6658b3dd21e4f2a0602d523a13150e2b48b770',
|
|
|
|
languages = [language]
|
|
|
|
'title': 'Social Media Exposed',
|
|
|
|
if language == 'en':
|
|
|
|
'description': 'md5:98af97317aacd5b85d595775ea37d80e',
|
|
|
|
languages.append('none')
|
|
|
|
},
|
|
|
|
params['any_languages'] = languages
|
|
|
|
'playlist_mincount': 34,
|
|
|
|
entries = OnDemandPagedList(
|
|
|
|
}, {
|
|
|
|
functools.partial(self._fetch_page, claim_id, url, params),
|
|
|
|
'url': 'https://odysee.com/$/playlist/938fb11d-215f-4d1c-ad64-723954df2184',
|
|
|
|
self._PAGE_SIZE)
|
|
|
|
'info_dict': {
|
|
|
|
result_value = result.get('value') or {}
|
|
|
|
'id': '938fb11d-215f-4d1c-ad64-723954df2184',
|
|
|
|
return self.playlist_result(
|
|
|
|
},
|
|
|
|
entries, claim_id, result_value.get('title'),
|
|
|
|
'playlist_mincount': 1000,
|
|
|
|
result_value.get('description'))
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
|
|
|
|
display_id = self._match_id(url)
|
|
|
|
|
|
|
|
result = traverse_obj(self._call_api_proxy('claim_search', display_id, {
|
|
|
|
|
|
|
|
'claim_ids': [display_id],
|
|
|
|
|
|
|
|
'no_totals': True,
|
|
|
|
|
|
|
|
'page': 1,
|
|
|
|
|
|
|
|
'page_size': self._PAGE_SIZE,
|
|
|
|
|
|
|
|
}, 'playlist'), ('items', 0))
|
|
|
|
|
|
|
|
claim_param = {'claim_ids': traverse_obj(result, ('value', 'claims', ..., {str}))}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return self._playlist_entries(url, display_id, claim_param, result)
|
|
|
|