Spaces:
Paused
Paused
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from imdb import IMDb
|
| 3 |
+
|
| 4 |
+
# Initialize IMDb object
|
| 5 |
+
ia = IMDb()
|
| 6 |
+
|
| 7 |
+
# Function to get movie embed URL
|
| 8 |
+
def get_movie_embed(imdb_id, ds_lang=None, sub_url=None):
|
| 9 |
+
base_url = "https://vidsrc.xyz/embed/movie"
|
| 10 |
+
params = f"?imdb={imdb_id}"
|
| 11 |
+
if ds_lang:
|
| 12 |
+
params += f"&ds_lang={ds_lang}"
|
| 13 |
+
if sub_url:
|
| 14 |
+
params += f"&sub_url={sub_url}"
|
| 15 |
+
return f"{base_url}{params}"
|
| 16 |
+
|
| 17 |
+
# Function to get TV show embed URL
|
| 18 |
+
def get_tv_embed(imdb_id, season=None, episode=None, ds_lang=None, sub_url=None):
|
| 19 |
+
base_url = "https://vidsrc.xyz/embed/tv"
|
| 20 |
+
if season and episode:
|
| 21 |
+
return f"{base_url}/{imdb_id}/{season}-{episode}"
|
| 22 |
+
params = f"?imdb={imdb_id}"
|
| 23 |
+
if ds_lang:
|
| 24 |
+
params += f"&ds_lang={ds_lang}"
|
| 25 |
+
if sub_url:
|
| 26 |
+
params += f"&sub_url={sub_url}"
|
| 27 |
+
return f"{base_url}{params}"
|
| 28 |
+
|
| 29 |
+
# Streamlit app layout
|
| 30 |
+
st.title("Vidsrc Embed URL Generator")
|
| 31 |
+
st.write("Search for a movie or TV show using IMDbPY and get the Vidsrc embed URL.")
|
| 32 |
+
|
| 33 |
+
# Input for search type
|
| 34 |
+
search_type = st.radio("Select type", ("Movie", "TV Show"))
|
| 35 |
+
|
| 36 |
+
# Input for search query
|
| 37 |
+
query = st.text_input("Search IMDb", "Enter the name of a movie or TV show")
|
| 38 |
+
|
| 39 |
+
# Optional inputs for additional parameters
|
| 40 |
+
ds_lang = st.text_input("Default subtitle language (ISO639 code)", "")
|
| 41 |
+
sub_url = st.text_input("Subtitle URL (with CORS enabled)", "")
|
| 42 |
+
|
| 43 |
+
# Search and display results
|
| 44 |
+
if st.button("Search"):
|
| 45 |
+
if query:
|
| 46 |
+
# Perform search
|
| 47 |
+
results = ia.search_movie(query)
|
| 48 |
+
|
| 49 |
+
# Display search results
|
| 50 |
+
if results:
|
| 51 |
+
st.write(f"Found {len(results)} results.")
|
| 52 |
+
for idx, result in enumerate(results):
|
| 53 |
+
st.write(f"{idx + 1}. {result['title']} ({result.get('year', 'N/A')})")
|
| 54 |
+
|
| 55 |
+
# Input for selection
|
| 56 |
+
selection = st.number_input("Select the number of the result", min_value=1, max_value=len(results))
|
| 57 |
+
|
| 58 |
+
selected_result = results[selection - 1]
|
| 59 |
+
imdb_id = selected_result.movieID
|
| 60 |
+
|
| 61 |
+
# Generate embed URL based on search type
|
| 62 |
+
if search_type == "Movie":
|
| 63 |
+
embed_url = get_movie_embed(imdb_id, ds_lang, sub_url)
|
| 64 |
+
else:
|
| 65 |
+
season = st.number_input("Season number", min_value=1)
|
| 66 |
+
episode = st.number_input("Episode number", min_value=1)
|
| 67 |
+
embed_url = get_tv_embed(imdb_id, season, episode, ds_lang, sub_url)
|
| 68 |
+
|
| 69 |
+
# Display the embed URL
|
| 70 |
+
st.write("Embed URL:")
|
| 71 |
+
st.write(embed_url)
|
| 72 |
+
else:
|
| 73 |
+
st.write("No results found.")
|
| 74 |
+
else:
|
| 75 |
+
st.write("Please enter a search query.")
|