Oconnor 0 Posted November 13, 2017 Share Posted November 13, 2017 Hello, I've been searching the web for an answer but failed to find one and could not think of one my self. But is there an API endpoint for information about the library? As in: Total movies in library Total shows Total episodes Total unwatched Total minuts wasted of my life on shows and movies And stuff like that. I've only started playing around with it and displaying it on my own local website and would like to add information like this.Is there a quick and easy way to get this information? Second not related question: This is not as important because I got it working(ish) - I'm trying to connect to the websocket using python and the program EventGhost to run the script and display the data. But I'm not sure if I am recieving all the notifications I should. As far as I understand I should get a notification whenever a user plays or pause a movie, starts or end a movie etc. Right now I do not get any notifications if the movie is playing or is paused. Here is the script: from ws4py.client.threadedclient import WebSocketClient import json class EmbyClient(WebSocketClient): def closed(self, code, reason): print "Closed down", code, reason def received_message(self, msg): job = json.loads(str(msg)) print msg message = job['MessageType'] #print message if message == "PlaybackStopped": eg.TriggerEvent("EmbyStop") elif message == "PlaybackStart": eg.TriggerEvent("EmbyStart") try: ws = EmbyClient('ws://**.*.*.**?api_key=****&deviceId=121212') ws.connect() except KeyboardInterrupt: ws.close() Anything I can do better here? Thanks in advance Link to comment Share on other sites More sharing options...
ebr 14948 Posted November 14, 2017 Share Posted November 14, 2017 A community member has created a plug-in to provide that type of information. It is called Emby Statistics and is in the catalog. Link to comment Share on other sites More sharing options...
Oconnor 0 Posted November 14, 2017 Author Share Posted November 14, 2017 Hello, Thanks for the respons @@ebr - I'm aware of this plugin, but the reason I am asking is because I have my own website that I use to display certain data. And I'd like to display some of the information I mentioned above. Link to comment Share on other sites More sharing options...
Luke 37179 Posted November 14, 2017 Share Posted November 14, 2017 Hi, for the first part, I would check out our wiki: https://github.com/MediaBrowser/Emby/wiki You can just do regular item queries and examine TotalRecordCount. Link to comment Share on other sites More sharing options...
Oconnor 0 Posted November 14, 2017 Author Share Posted November 14, 2017 Thanks for the respons @@Luke - I'll look into it. Link to comment Share on other sites More sharing options...
holdestmade 11 Posted March 8, 2018 Share Posted March 8, 2018 (edited) #Oconnor - did you get anywhere with this, I am doing something very similar in eventghost and I'm not getting 'paused' events also ? This is what I have working now that sends the nowplaying info to my RTI processor for display on remotes/tablets. It sends 7 lines of text that varies depending on what is playing. I had to add try, excepts for some of the metadata as not all my media has those and was causing an exception, I guess I should add it for all just in case. from ws4py.client.threadedclient import WebSocketClient import json class EmbyClient(WebSocketClient): def closed(self, code, reason): eg.PrintError("Closed Down" + str(code) + str(reason)) def received_message(self,msg): job = json.loads(str(msg)) #print job try: subtitle = job['Data']['DeviceName'] except: try: subtitle = job['Data']['Key'] except: subtitle = "" message = job['MessageType'] eg.TriggerEvent(subtitle + "." + str(message), prefix="emby") if message == "PlaybackStopped": eg.plugins.RTISimpelTCPServer.SendString('EMBY_Playback@Stopped#') for x in range (1,8): eg.plugins.RTISimpelTCPServer.SendString('EMBY_Playing' + str(x) + '@ #') if message == "PlaybackStart": metadata = [' ', ' ', ' ', ' ', ' ', ' ', ' '] eg.plugins.RTISimpelTCPServer.SendString('EMBY_Playback@Started#') Type = job['Data']['NowPlayingItem']['Type'] if Type == 'Episode': metadata[1] = job['Data']['NowPlayingItem']['SeriesName'] metadata[5] = str(job['Data']['NowPlayingItem']['ParentIndexNumber']) + "x" + str(job['Data']['NowPlayingItem']['IndexNumber']) metadata[6] = job['Data']['NowPlayingItem']['Overview'] elif Type == 'Movie': try: metadata[3] = job['Data']['NowPlayingItem']['OfficialRating'] except: pass metadata[6] = job['Data']['NowPlayingItem']['Overview'] elif Type == 'Audio': try: metadata[1] = job['Data']['NowPlayingItem']['AlbumArtist'] except: pass try: metadata[6] = job['Data']['NowPlayingItem']['Album'] except: pass metadata[0] = job['Data']['NowPlayingItem']['Name'] try: metadata[2] = str(job['Data']['NowPlayingItem']['ProductionYear']) except: pass Genres = job['Data']['NowPlayingItem']['Genres'] metadata[4] = ', '.join(Genres) for x in range (1,8): print metadata[x-1] eg.plugins.RTISimpelTCPServer.SendString('EMBY_Playing' + str(x) + '@' + metadata[x-1] + '#') try: ws = EmbyClient('ws://192.168.x.x:8096?api_key=xxxxxxxxxxxxxxxxxxxxxxx&deviceId=xxxxxxxxxxxxxxxxxxxxxx') ws.connect() eg.PrintNotice("Connected to EMBY Server") except: ws.close() Thanks Edited March 8, 2018 by holdestmade Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now