File size: 2,822 Bytes
a90e1b8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8bad137
a90e1b8
 
 
 
 
 
 
 
 
8bad137
 
a90e1b8
 
 
 
 
 
 
 
8bad137
 
a90e1b8
 
 
 
 
 
 
 
 
4429eba
 
8bad137
 
 
 
1181585
 
 
 
4429eba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a90e1b8
4429eba
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import streamlit as st
from imdb import IMDb

# Initialize IMDb object
ia = IMDb()

# Function to get movie embed URL
def get_movie_embed(imdb_id, ds_lang=None, sub_url=None):
    base_url = "https://vidsrc.xyz/embed/movie"
    params = f"?imdb={imdb_id}"
    if ds_lang:
        params += f"&ds_lang={ds_lang}"
    if sub_url:
        params += f"&sub_url={sub_url}"
    return f"{base_url}{params}"

# Function to get TV show embed URL
def get_tv_embed(imdb_id, season=None, episode=None, ds_lang=None, sub_url=None):
    base_url = "https://vidsrc.xyz/embed/tv"
    params = f"?imdb={imdb_id}"
    if season and episode:
        return f"{base_url}/{imdb_id}/{season}-{episode}"
    if ds_lang:
        params += f"&ds_lang={ds_lang}"
    if sub_url:
        params += f"&sub_url={sub_url}"
    return f"{base_url}{params}"

# Streamlit app layout
st.title("WATCH ONLINE MOVIES FOR FREE")
st.write("Search for a movie or TV show")

# Input for search type
search_type = st.radio("Select type", ("Movie", "TV Show"))

# Input for search query
query = st.text_input("Search IMDb", "Enter the name of a movie or TV show")

# Optional inputs for additional parameters
ds_lang = st.text_input("Default subtitle language (Leave it empty if you do not want to use it)", "")
sub_url = st.text_input("Subtitle URL (Leave it empty if you do not want to use it)", "")

# Search and display results
if st.button("Search"):
    if query:
        # Perform search
        results = ia.search_movie(query)
        
        # Display search results
        if results:
            st.write(f"Found {len(results)} results. Displaying up to 20 results:")
            for idx, result in enumerate(results[:5]):  # Limit to 20 results
                title = result.get('title', 'Unknown title')
                year = result.get('year', 'N/A')
                imdb_id = result.movieID
                
                # Fetch poster URL
                ia.update(result, info=['main'])
                poster_url = result.get('full-size cover url', None)
                
                # Display poster, title, and year
                st.write(f"{idx + 1}. {title} ({year})")
                if poster_url:
                    st.image(poster_url, width=150)
                
                # Generate embed URL based on search type
                if search_type == "Movie":
                    embed_url = get_movie_embed(imdb_id, ds_lang, sub_url)
                else:
                    embed_url = get_tv_embed(imdb_id, ds_lang=ds_lang, sub_url=sub_url)
                
                # Display the embed URL
                st.write("URL:")
                st.write(embed_url)
                st.write("---")
        else:
            st.write("No results found.")
    else:
        st.write("Please enter a search query.")