mirror of
https://github.com/sfiorini/iptv-server.git
synced 2026-04-11 10:40:45 +00:00
Save and retrieve playlists and epg guides from vercel blob storage
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from upstash_redis import Redis as UpstashRedis
|
||||
from redis import Redis as LocalRedis, RedisError
|
||||
import vercel_blob
|
||||
from src.config import REDIS_URL, REDIS_TOKEN, USE_LOCAL_REDIS, LOCAL_REDIS_URL
|
||||
from fastapi import HTTPException
|
||||
import logging
|
||||
@@ -33,4 +34,21 @@ except RedisError as re:
|
||||
raise HTTPException(status_code=500, detail="Database connection error")
|
||||
except Exception as e:
|
||||
logger.error(f"Unexpected error while connecting to Redis: {str(e)}")
|
||||
raise HTTPException(status_code=500, detail="Internal server error")
|
||||
raise HTTPException(status_code=500, detail="Internal server error")
|
||||
|
||||
def get_blob_by_path(folder: str, filename: str) -> dict:
|
||||
# Get list of all blobs
|
||||
resp = vercel_blob.list()
|
||||
|
||||
# Search for matching blob path
|
||||
target_path = f"{folder}/{filename}"
|
||||
matching_blob = next(
|
||||
(blob for blob in resp.get('blobs', [])
|
||||
if blob.get('pathname') == target_path),
|
||||
None
|
||||
)
|
||||
|
||||
if not matching_blob:
|
||||
raise HTTPException(status_code=404, detail="File not found")
|
||||
|
||||
return matching_blob
|
||||
Reference in New Issue
Block a user