Najeebsk

MOVEIS-SEARCH-2.py

Mar 15th, 2024 (edited)
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.68 KB | None | 0 0
  1. import tkinter as tk
  2. from tkinter import scrolledtext, ttk
  3. import subprocess
  4. import webbrowser
  5. from imdb import IMDb
  6.  
  7. # Dictionary to store the movie sites and their corresponding URLs
  8. movie_sites = {
  9.     "Zoechip": "https://www3.zoechip.com/search/",
  10.     "Onionplay": "https://onionplay.se/search/",
  11.     "Showbox": "https://www.showbox.media/search?keyword=",
  12.     "IMDb": "https://www.imdb.com/find/?q=",
  13.     "PutLockers": "https://putlockers.vg/search?q=",
  14.     "TubiTV": "https://tubitv.com/search/",
  15.     "YouTube": "https://www.youtube.com/results?sp=mAEB&search_query=",
  16.     "M4ufree+.html": "https://m4ufree.vip/search/",    
  17. }
  18.  
  19. def search_movies():
  20.     keyword = entry_search.get()
  21.     ia = IMDb()
  22.     movies = ia.search_movie(keyword)
  23.     result_text.delete('1.0', tk.END)
  24.     if not movies:
  25.         result_text.insert(tk.END, "No results found.")
  26.     else:
  27.         for movie in movies[:10]:  # Displaying the first 10 results
  28.             title = movie['title']
  29.             year = movie.get('year', 'N/A')  # Get the year if available, otherwise use 'N/A'
  30.             result_text.insert(tk.END, f"{title} ({year})\n")
  31.             if 'imdb_id' in movie:
  32.                 link = f"https://www.imdb.com/title/{movie['imdb_id']}/"
  33.                 result_text.insert(tk.END, f"Link: {link}\n\n")
  34.             else:
  35.                 result_text.insert(tk.END, "\n")
  36.  
  37. def open_browser():
  38.     selected_text = result_text.tag_ranges(tk.SEL)
  39.     if selected_text:
  40.         selected_movie_link = result_text.get(*selected_text).strip()
  41.         selected_movie_site = movie_site_combobox.get()  # Get the selected movie site from the combobox
  42.         if selected_movie_link.startswith("http://") or selected_movie_link.startswith("https://"):
  43.             webbrowser.open(selected_movie_link)
  44.         else:
  45.             # Get the URL corresponding to the selected movie site
  46.             movie_site_url = movie_sites.get(selected_movie_site)
  47.             if movie_site_url:
  48.                 # Construct the full URL with the selected movie title
  49.                 full_url = f"{movie_site_url}{selected_movie_link}"  #.html
  50.                 webbrowser.open(full_url)
  51.  
  52. # GUI
  53. root = tk.Tk()
  54. root.title("Movie Search")
  55.  
  56. # Define colors
  57. background_color = '#333333'
  58. text_color = '#FFFFFF'
  59. button_color = '#4CAF50'
  60. button_text_color = '#FFFFFF'
  61.  
  62. root.config(bg=background_color)
  63.  
  64. frame_search = tk.Frame(root, bg=background_color)
  65. frame_search.pack(pady=10)
  66.  
  67. label_search = tk.Label(frame_search, text="Enter Movie Name:", bg=background_color, fg=text_color)
  68. label_search.pack(side=tk.LEFT)
  69.  
  70. entry_search = tk.Entry(frame_search, width=30)
  71. entry_search.pack(side=tk.LEFT)
  72.  
  73. button_search = tk.Button(frame_search, text="Search", command=search_movies, bg=button_color, fg=button_text_color)
  74. button_search.pack(side=tk.LEFT, padx=10)
  75.  
  76. frame_result = tk.Frame(root, bg=background_color)
  77. frame_result.pack(pady=10)
  78.  
  79. result_text = scrolledtext.ScrolledText(frame_result, width=50, height=20, bg=background_color, fg=text_color)
  80. result_text.pack(side=tk.LEFT)
  81.  
  82. frame_options = tk.Frame(root, bg=background_color)
  83. frame_options.pack(pady=10)
  84.  
  85. # Dropdown for selecting movie site
  86. label_site = tk.Label(frame_options, text="Select Movie Site:", bg=background_color, fg=text_color)
  87. label_site.pack(side=tk.LEFT)
  88.  
  89. movie_site_combobox = ttk.Combobox(frame_options, values=list(movie_sites.keys()), state="readonly")
  90. movie_site_combobox.pack(side=tk.LEFT, padx=10)
  91. movie_site_combobox.current(0)  # Set default value
  92.  
  93. button_open_browser = tk.Button(frame_options, text="Open in Browser", command=open_browser, bg=button_color, fg=button_text_color)
  94. button_open_browser.pack(side=tk.LEFT)
  95.  
  96. root.mainloop()
  97.  
Add Comment
Please, Sign In to add comment