Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Plex server details
- baseurl = 'http://192.168.0.47:32400'
- token = 'WgxN5MCyBmTxAVmJMPr8' # Your Plex token
- # Connect to Plex server
- plex = PlexServer(baseurl, token)
- # Get currently playing media from the server
- print("Currently Playing Media on the Plex Server:")
- sessions = plex.sessions() # Get all active sessions
- if not sessions:
- print("No media is currently being played on the server.")
- else:
- for session in sessions:
- client_title = session.player.title # Access the client title
- media_title = session.title # Access the media title
- media_type = session.type # Access the media type
- print(f"\nClient: {client_title}")
- print(f" Playing: {media_title} ({media_type})")
- # Additional details for media
- if hasattr(session, 'grandparentTitle'):
- print(f" Series: {session.grandparentTitle}") # For TV shows
- if hasattr(session, 'year'):
- print(f" Year: {session.year}") # For movies
- if hasattr(session, 'summary'):
- print(f" Summary: {session.summary}") # Summary of the media
Advertisement
Add Comment
Please, Sign In to add comment