Jump to content

Library information


Oconnor

Recommended Posts

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

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

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

  • 3 months later...
holdestmade

#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 by holdestmade
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...