2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_str
17 class LBRYIE(InfoExtractor
):
19 _VALID_URL
= r
'https?://(?:www\.)?(?:lbry\.tv|odysee\.com)/(?P<id>@[0-9a-zA-Z-]+:[0-9a-z]+/[0-9a-zA-Z().-]+:[0-9a-z])'
22 'url': 'https://lbry.tv/@Mantega:1/First-day-LBRY:1',
23 'md5': '65bd7ec1f6744ada55da8e4c48a2edf9',
25 'id': '17f983b61f53091fb8ea58a9c56804e4ff8cff4d',
27 'title': 'First day in LBRY? Start HERE!',
28 'description': 'md5:f6cb5c704b332d37f5119313c2c98f51',
29 'timestamp': 1595694354,
30 'upload_date': '20200725',
34 'url': 'https://lbry.tv/@LBRYFoundation:0/Episode-1:e',
35 'md5': 'c94017d3eba9b49ce085a8fad6b98d00',
37 'id': 'e7d93d772bd87e2b62d5ab993c1c3ced86ebb396',
39 'title': 'The LBRY Foundation Community Podcast Episode 1 - Introduction, Streaming on LBRY, Transcoding',
40 'description': 'md5:661ac4f1db09f31728931d7b88807a61',
41 'timestamp': 1591312601,
42 'upload_date': '20200604',
45 'url': 'https://odysee.com/@BrodieRobertson:5/apple-is-tracking-everything-you-do-on:e',
46 'only_matching': True,
49 def _call_api_proxy(self
, method
, display_id
, params
):
50 return self
._download
_json
(
51 'https://api.lbry.tv/api/v1/proxy', display_id
,
52 headers
={'Content-Type': 'application/json-rpc'}
,
56 }).encode())['result']
58 def _real_extract(self
, url
):
59 display_id
= self
._match
_id
(url
).replace(':', '#')
60 uri
= 'lbry://' + display_id
61 result
= self
._call
_api
_proxy
(
62 'resolve', display_id
, {'urls': [uri]}
)[uri
]
63 result_value
= result
['value']
64 if result_value
.get('stream_type') not in ('video', 'audio'):
65 raise ExtractorError('Unsupported URL', expected
=True)
66 streaming_url
= self
._call
_api
_proxy
(
67 'get', display_id
, {'uri': uri}
)['streaming_url']
68 source
= result_value
.get('source') or {}
69 media
= result_value
.get('video') or result_value
.get('audio') or {}
70 signing_channel
= result_value
.get('signing_channel') or {}
73 'id': result
['claim_id'],
74 'title': result_value
['title'],
75 'thumbnail': try_get(result_value
, lambda x
: x
['thumbnail']['url'], compat_str
),
76 'description': result_value
.get('description'),
77 'license': result_value
.get('license'),
78 'timestamp': int_or_none(result
.get('timestamp')),
79 'tags': result_value
.get('tags'),
80 'width': int_or_none(media
.get('width')),
81 'height': int_or_none(media
.get('height')),
82 'duration': int_or_none(media
.get('duration')),
83 'channel': signing_channel
.get('name'),
84 'channel_id': signing_channel
.get('claim_id'),
85 'ext': determine_ext(source
.get('name')) or mimetype2ext(source
.get('media_type')),
86 'filesize': int_or_none(source
.get('size')),