From 16140c117cd4391811b9b3ab5b6504f0f6fbfb73 Mon Sep 17 00:00:00 2001 From: Tristan Lee Date: Fri, 25 Feb 2022 17:49:12 -0600 Subject: [PATCH] accounted for more video edge cases --- polyphemus/api.py | 8 ++++---- polyphemus/base.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/polyphemus/api.py b/polyphemus/api.py index 1a9aaf2..f176338 100644 --- a/polyphemus/api.py +++ b/polyphemus/api.py @@ -50,11 +50,11 @@ def get_channel_info(channel_name): info = { 'channel_id' : info['claim_id'], - 'title' : info['value']['title'], + 'title' : info['value'].get('title'), 'created': info['timestamp'], - 'description': info['value']['description'], - 'cover_image': info['value']['cover']['url'], - 'thumbnail_image': info['value']['thumbnail']['url'], + 'description': info['value'].get('description'), + 'cover_image': info['value'].get('cover',{}).get('url'), + 'thumbnail_image': info['value'].get('thumbnail',{}).get('url'), 'raw' : response.text} return info diff --git a/polyphemus/base.py b/polyphemus/base.py index 8852805..c557afe 100644 --- a/polyphemus/base.py +++ b/polyphemus/base.py @@ -6,7 +6,7 @@ #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++# import json -from urllib.parse import quote +from dataclasses import dataclass from polyphemus import api @@ -78,8 +78,14 @@ class OdyseeVideo: elif 'audio' in full_video_info['value']: video_type = 'audio' duration = full_video_info['value']['audio'].get('duration') + elif 'claim_hash' in full_video_info['value']: + video_type = 'repost' + duration = None + + full_video_info['value'] = full_video_info['reposted_claim']['value'] + else: - raise KeyError(f'nether `video` or `audio` keys are in `full_video_info["value"]`, only {full_video_info["value"].keys()}') + raise KeyError(f'nether `video`, `audio`, nor `claim_hash` keys are in `full_video_info["value"]`, only {full_video_info["value"].keys()}') if 'signing_channel' in full_video_info: channel_name = full_video_info['signing_channel'].get('name')