File size: 1,934 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
38
39
40
41
42
43
44
45
46
47
48
49
import requests
import json

class AutoEmbed:
    def __init__(self):
        self.base_url = "https://tom.autoembed.cc/api/getVideoSource"
        self.headers = {
            'Referer': 'https://tom.autoembed.cc',
            'Origin': 'https://tom.autoembed.cc',
        }
        self.videoDataList = []
    
    def build_url(self, imdb_id, media_type, season = None, episode = None):
        final_url = f"{self.base_url}?type={media_type}&id={imdb_id}"
        if season and episode and media_type == 'tv':
            final_url += f"/{season}/{episode}"
        return final_url
    
    def get_stream(self, tmdb_id, imdb_id, media_type, title, year, season = None, episode = None):
        final_url = self.build_url(media_type=media_type, imdb_id=imdb_id, season=season, episode=episode)
        response = requests.get(final_url, headers=self.headers)
        if response.status_code == 200:
            data = response.json()
            if 'videoSource' in data:
                self.videoDataList.append(
                    {
                        "videoSource" : f"AUTOEMBED1_{len(self.videoDataList)+1}",
                        "videoUrl" : data['videoSource'],
                        "videoHeaders": {}
                    }
                )
        else:
            raise Exception("Failed to get encoded data")
        return self.videoDataList
        
if __name__ == "__main__":
    auto_embed = AutoEmbed()
    media_type = "movie"
    tmdb_id = "822119"
    imdb_id = "tt14513804"
    title = "Captain America: Brave New World"
    year = "2025"
    season = None
    episode = None
    try:
        encoded_data = auto_embed.get_stream(tmdb_id=tmdb_id, imdb_id=imdb_id, media_type=media_type, title=title, year=year, season=season, episode=episode)
        print(json.dumps(encoded_data, indent=4))
    except Exception as e:
        print(f"Error: {e}")