File size: 1,536 Bytes
e37348d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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