streamora_backend / helpers /functions.py
raannakasturi's picture
Add initial implementation of streaming service with multiple providers
e37348d
raw
history blame contribute delete
766 Bytes
import base64
import requests
class Utils:
def __init__(self):
pass
def b64_decode(self, input_str):
input_str = self.fix_padding(input_str)
try:
return base64.b64decode(input_str).decode('utf-8')
except Exception as e:
raise ValueError(f"Decoding failed: {e}")
def fix_padding(self, input_str):
padding = len(input_str) % 4
if padding:
input_str += "=" * (4 - padding)
return input_str
def is_accessible(self, url, headers=None):
try:
response = requests.head(url, headers=headers, timeout=10)
return response.status_code in [200, 302]
except:
return False