slimshadow commited on
Commit
8bad137
·
verified ·
1 Parent(s): a90e1b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -26
app.py CHANGED
@@ -17,9 +17,9 @@ def get_movie_embed(imdb_id, ds_lang=None, sub_url=None):
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:
@@ -27,8 +27,8 @@ def get_tv_embed(imdb_id, season=None, episode=None, ds_lang=None, sub_url=None)
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"))
@@ -37,8 +37,8 @@ search_type = st.radio("Select type", ("Movie", "TV Show"))
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"):
@@ -48,27 +48,24 @@ if st.button("Search"):
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:
 
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
+ params = f"?imdb={imdb_id}"
21
  if season and episode:
22
  return f"{base_url}/{imdb_id}/{season}-{episode}"
 
23
  if ds_lang:
24
  params += f"&ds_lang={ds_lang}"
25
  if sub_url:
 
27
  return f"{base_url}{params}"
28
 
29
  # Streamlit app layout
30
+ st.title("WATCH ONLINE MOVIES FOR FREE")
31
+ st.write("Search for a movie or TV show")
32
 
33
  # Input for search type
34
  search_type = st.radio("Select type", ("Movie", "TV Show"))
 
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 (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"):
 
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[:20]): # Limit to 20 results
53
+ title = result.get('title', 'Unknown title')
54
+ year = result.get('year', 'N/A')
55
+ imdb_id = result.movieID
56
+
57
+ st.write(f"{idx + 1}. {title} ({year})")
58
+
59
+ # Generate embed URL based on search type
60
+ if search_type == "Movie":
61
+ embed_url = get_movie_embed(imdb_id, ds_lang, sub_url)
62
+ else:
63
+ embed_url = get_tv_embed(imdb_id, ds_lang=ds_lang, sub_url=sub_url)
64
+
65
+ # Display the embed URL
66
+ st.write("Embed URL:")
67
+ st.write(embed_url)
68
+ st.write("---")
 
 
 
69
  else:
70
  st.write("No results found.")
71
  else: