Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -40,10 +40,6 @@ query = st.text_input("Search IMDb", "Enter the name of a movie or TV show")
|
|
| 40 |
ds_lang = st.text_input("Default subtitle language (Leave it empty if you do not want to use it)", "")
|
| 41 |
sub_url = st.text_input("Subtitle URL (Leave it empty if you do not want to use it)", "")
|
| 42 |
|
| 43 |
-
# Initialize variables
|
| 44 |
-
results = []
|
| 45 |
-
selected_title = None
|
| 46 |
-
|
| 47 |
# Search and display results
|
| 48 |
if st.button("Search"):
|
| 49 |
if query:
|
|
@@ -52,10 +48,8 @@ if st.button("Search"):
|
|
| 52 |
|
| 53 |
# Display search results
|
| 54 |
if results:
|
| 55 |
-
st.write(f"Found {len(results)} results. Displaying
|
| 56 |
-
|
| 57 |
-
posters = []
|
| 58 |
-
for idx, result in enumerate(results[:5]): # Limit to 5 results
|
| 59 |
title = result.get('title', 'Unknown title')
|
| 60 |
year = result.get('year', 'N/A')
|
| 61 |
imdb_id = result.movieID
|
|
@@ -64,24 +58,22 @@ if st.button("Search"):
|
|
| 64 |
ia.update(result, info=['main'])
|
| 65 |
poster_url = result.get('full-size cover url', None)
|
| 66 |
|
| 67 |
-
#
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
|
|
|
|
|
|
| 82 |
else:
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
# Display the selected movie or TV show using an iframe
|
| 86 |
-
st.write("Playing:")
|
| 87 |
-
st.markdown(f'<iframe src="{embed_url}" width="700" height="400" frameborder="0" allowfullscreen></iframe>', unsafe_allow_html=True)
|
|
|
|
| 40 |
ds_lang = st.text_input("Default subtitle language (Leave it empty if you do not want to use it)", "")
|
| 41 |
sub_url = st.text_input("Subtitle URL (Leave it empty if you do not want to use it)", "")
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
# Search and display results
|
| 44 |
if st.button("Search"):
|
| 45 |
if query:
|
|
|
|
| 48 |
|
| 49 |
# Display search results
|
| 50 |
if results:
|
| 51 |
+
st.write(f"Found {len(results)} results. Displaying up to 20 results:")
|
| 52 |
+
for idx, result in enumerate(results[:5]): # Limit to 20 results
|
|
|
|
|
|
|
| 53 |
title = result.get('title', 'Unknown title')
|
| 54 |
year = result.get('year', 'N/A')
|
| 55 |
imdb_id = result.movieID
|
|
|
|
| 58 |
ia.update(result, info=['main'])
|
| 59 |
poster_url = result.get('full-size cover url', None)
|
| 60 |
|
| 61 |
+
# Display poster, title, and year
|
| 62 |
+
st.write(f"{idx + 1}. {title} ({year})")
|
| 63 |
+
if poster_url:
|
| 64 |
+
st.image(poster_url, width=150)
|
| 65 |
+
|
| 66 |
+
# Generate embed URL based on search type
|
| 67 |
+
if search_type == "Movie":
|
| 68 |
+
embed_url = get_movie_embed(imdb_id, ds_lang, sub_url)
|
| 69 |
+
else:
|
| 70 |
+
embed_url = get_tv_embed(imdb_id, ds_lang=ds_lang, sub_url=sub_url)
|
| 71 |
+
|
| 72 |
+
# Display the embed URL
|
| 73 |
+
st.write("URL:")
|
| 74 |
+
st.write(embed_url)
|
| 75 |
+
st.write("---")
|
| 76 |
+
else:
|
| 77 |
+
st.write("No results found.")
|
| 78 |
else:
|
| 79 |
+
st.write("Please enter a search query.")
|
|
|
|
|
|
|
|
|
|
|
|