this post was submitted on 28 May 2024
24 points (96.2% liked)
Jellyfin: The Free Software Media System
5852 readers
18 users here now
Current stable release: 10.10.3
Matrix (General Information & Help)
Matrix (Off-Topic) - Come get to know the team and blow off steam!
Matrix Space - List of all the available rooms on Matrix.
Discord - Bridged to our Matrix rooms
founded 4 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Yep, the api in jellyfin is quite easy. Someone already sent the link to the docs. The specific endpoint you want is Sessions. You need to get yourself an api_key which you can get in the admin panel. Here is an example code in Python to give you an idea on how to use the api:
If it is indeed Python that you want to use, you can adjust it to your needs depending on what you want it to output.
Basically, it is as simple as looping through every current session and checking if they have a NowPlayingItem key which is only present when they have a video open (both playing and paused). It works very reliability, I am using it to automatically change my lights when I watch a long video or movie.
Thank you!
I wrote a bash script that powers off the computer when there was no user activity for 10 minutes.
Neat and handy! I guess you could write some wake-on-LAN shenanigans to make it turn on when a user is trying to connect aswell 👍
Wow, that would be next level!