raannakasturi's picture
Add initial implementation of streaming service with multiple providers
e37348d
import json
import urllib.parse
import requests
from helpers.functions import Utils
class Vidzee:
def __init__(self):
self.video_data_list = []
self.utils = Utils()
def get_stream(self, imdb_id, tmdb_id, media_type, title, year, season=None, episode=None):
base_url = f"https://vidzee.wtf/{media_type}/player.php?id={tmdb_id}"
if media_type == "tv" and season is not None and episode is not None:
base_url += f"&season={season}&episode={episode}"
try:
response = requests.get(base_url)
if response.status_code != 200:
return []
data = response.text
sources_raw = data.split("data-stream-sources='")[1].split("]'")[0] + "]"
servers = json.loads(sources_raw)
for server in servers:
video_label = server.get("label")
raw_url = server.get("url", "")
decoded_url = urllib.parse.unquote(raw_url.split("url=")[1])
if self.utils.is_accessible(decoded_url) and not any(d['videoUrl'] == decoded_url for d in self.video_data_list):
self.video_data_list.append({
"videoSource": f"VIDZEE_{len(self.video_data_list) + 1} ({video_label})",
"videoUrl": decoded_url,
"videoHeaders": {}
})
except Exception as e:
print(f"Error: {e}")
return self.video_data_list