From 72ea0a63de4b40bf8038dfdb26cbbab87ba86da9 Mon Sep 17 00:00:00 2001 From: Tristan Lee Date: Fri, 25 Feb 2022 19:35:31 -0600 Subject: [PATCH] added method to get streaming URL for a given video --- polyphemus/api.py | 16 ++++++++++++++++ polyphemus/base.py | 7 +++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/polyphemus/api.py b/polyphemus/api.py index f176338..0d64660 100644 --- a/polyphemus/api.py +++ b/polyphemus/api.py @@ -289,4 +289,20 @@ def name_to_video_info(name): return result['result'][video_url] +#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++# + +def get_streaming_url(canonical_url): + + json_data = { + "jsonrpc":"2.0", + "method":"get", + "params":{ + "uri":canonical_url}} + + result = requests.post(url = BACKEND_API_URL, json = json_data ) + + video_url = json.loads(result.text)['result'].get('streaming_url') + + return video_url + #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++# \ No newline at end of file diff --git a/polyphemus/base.py b/polyphemus/base.py index c557afe..0400028 100644 --- a/polyphemus/base.py +++ b/polyphemus/base.py @@ -83,6 +83,7 @@ class OdyseeVideo: duration = None full_video_info['value'] = full_video_info['reposted_claim']['value'] + full_video_info['canonical_url'] = full_video_info['reposted_claim']['canonical_url'] else: raise KeyError(f'nether `video`, `audio`, nor `claim_hash` keys are in `full_video_info["value"]`, only {full_video_info["value"].keys()}') @@ -116,7 +117,7 @@ class OdyseeVideo: 'channel_id' : channel_id, 'channel' : channel_name, 'claim_id' : full_video_info['claim_id'], - 'created' : created, + 'created' : int(created), 'description' : full_video_info['value'].get('description'), 'languages' : full_video_info['value'].get('languages'), 'tags' : full_video_info['value'].get('tags',[]), @@ -131,7 +132,9 @@ class OdyseeVideo: self.info['likes'], self.info['dislikes']= api.get_video_reactions( claim_id = self._claim_id) - + + self.info['streaming_url'] = api.get_streaming_url(self.info['canonical_url']) + #-------------------------------------------------------------------------# def get_all_comments(self):