bareddit will no longer be maintained by me (metalune) because gophereddit exists https://bareddit.metalune.xyz
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 

35 lines
1.2 KiB

# --------------------------------------------------------------- Imports ---------------------------------------------------------------- #
# System
from typing import Dict, List, Optional, Tuple
# Pip
from kcu import strings
# ---------------------------------------------------------------------------------------------------------------------------------------- #
# ------------------------------------------------------------- class: Image ------------------------------------------------------------- #
class Image:
# ------------------------------------------------------------- Init ------------------------------------------------------------- #
def __init__(
self,
preview_dict: Dict
):
try:
img_dict = preview_dict['images'][0]['source']
self.url = 'https://i.redd.it/' + strings.between(img_dict['url'], 'redd.it/', '?')
self.width = img_dict['width']
self.height = img_dict['height']
except:
self.url = None
self.width = None
self.height = None
# ---------------------------------------------------------------------------------------------------------------------------------------- #