Files
NotPlexServer/client.py

37 lines
917 B
Python

import requests
import webbrowser
API_BASE_URL = "http://localhost:8000"
def list_movies():
url = f"{API_BASE_URL}/movies"
try:
response = requests.get(url)
response.raise_for_status()
except Exception as e:
print(f"Error fetching movies: {e}")
return []
return response.json()
def main():
movies = list_movies()
if not movies:
print("No movies found.")
return
print("Available Movies:")
for movie in movies:
print(f"{movie['id']}: {movie.get('title', 'Unknown Title')}")
try:
movie_id = int(input("Enter movie ID to stream: "))
except ValueError:
print("Invalid input. Please enter a numeric movie ID.")
return
stream_url = f"{API_BASE_URL}/stream/{movie_id}"
print(f"Opening stream for movie ID {movie_id}...")
webbrowser.open(stream_url)
if __name__ == "__main__":
main()