Jump to content

Emby Xpath Url?


Recommended Posts

Dodgexander
Posted

 

Try omitting this request header because you're not sending xml:

-H "Content-Type: application/xml"

Yes! In chrome I was able to successfully use:

http://192.168.50.149:8096/emby/Users/Public?api_key=be367fefc07547bb8c77206a91046e09&format=xml

But trying:

http://192.168.50.149:8096/emby/Sessions?api_key=be367fefc07547bb8c77206a91046e09&format=xml

Results in:

 

Type 'MediaBrowser.Api.Session.PostFullCapabilities' with data contract name 'PostFullCapabilities:http://schemas.datacontract.org/2004/07/MediaBrowser.Api.Session' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.

 

Posted

We'll have to look at that. I would really try to use json if at all possible.

Dodgexander
Posted

What would be a simple method of writing a command to run to determine if a session is active. It needs to return 0 if active.

 

I have no idea how to retrieve the ActiveWithinSeconds using the API.

Posted

that's a filter you would use, so if you only wanted sessions active in the last five minutes you could do &ActiveWithinSeconds =300

Dodgexander
Posted

I'm really out of my depth here. Since I'm no developer I think I will have to give up trying to do what I am. Its been hard enough for me even to pull the entire /Sessions API, let alone create something that can find a specific parameter within that API.

 

I suppose knowledge of JSON/Javascript is required, which I simply don't have.

  • 8 months later...
Dodgexander
Posted

The author of Autosuspend has just updated to include JSON support and I'm revisiting this to try and create a way for my home server to sleep when not in use.

As a test I am using postman to make requests from the api but I can't return anything with ActiveWithinSeconds=300

I'm sure its because I don't really know code, but how do you use a filter like this with the API? I read the documentation but it doesn't seem to have anything on filters.

 

 

Posted

Well first, what have you tried? What does your request look like?

Dodgexander
Posted

I've tried:

http://192.168.50.149:8096/emby/Sessions?api_key=5e943480810a46428a8d0acc1772b01d&Filters=ActiveWithinSeconds=300

&

http://192.168.50.149:8096/emby/Sessions?api_key=5e943480810a46428a8d0acc1772b01d&ActiveWithinSeconds=300

It returns everything from the sessions api:

[
    {
        "PlayState": {
            "CanSeek": false,
            "IsPaused": false,
            "IsMuted": false,
            "RepeatMode": "RepeatNone",
            "SubtitleOffset": 0,
            "PlaybackRate": 1
        },
        "AdditionalUsers": [],
        "RemoteEndPoint": "192.168.50.164",
        "PlayableMediaTypes": [],
        "PlaylistIndex": 0,
        "PlaylistLength": 0,
        "Id": "a611a8042b0513cfc1ac32cfce0f7f9f",
        "ServerId": "55e0f60cf1144b1faf763cd54a952bd6",
        "Client": "Default",
        "LastActivityDate": "2020-12-04T00:56:09.5370351Z",
        "DeviceName": "basement",
        "DeviceId": "55e0f60cf1144b1faf763cd54a952bd6",
        "ApplicationVersion": "4.5.2.0",
        "SupportedCommands": [],
        "SupportsRemoteControl": false
    },
    {
        "PlayState": {
            "PositionTicks": 48682273039,
            "CanSeek": true,
            "IsPaused": false,
            "IsMuted": true,
            "VolumeLevel": 100,
            "AudioStreamIndex": 1,
            "MediaSourceId": "a134f3486ede1731bb6fba39aa05c417",
            "PlayMethod": "Transcode",
            "RepeatMode": "RepeatNone",
            "SubtitleOffset": 0,
            "PlaybackRate": 1
        },
        "AdditionalUsers": [],
        "RemoteEndPoint": "192.168.50.164",
        "PlayableMediaTypes": [
            "Audio",
            "Video"
        ],
        "PlaylistIndex": 0,
        "PlaylistLength": 1,
        "Id": "fd94a9a63887dccfac667b8591696320",
        "ServerId": "55e0f60cf1144b1faf763cd54a952bd6",
        "UserId": "fa4035f8f1db4537a273a9c881a8f5e3",
        "UserName": "tim",
        "UserPrimaryImageTag": "1b8ca499db786db3e12fb6abfa3b9db4",
        "Client": "Emby Web",
        "LastActivityDate": "2020-12-04T00:56:08.9471627Z",
        "DeviceName": "Chrome",
        "NowPlayingItem": {
            "Name": "Transporter 3",
            "OriginalTitle": "Transporter 3",
            "ServerId": "55e0f60cf1144b1faf763cd54a952bd6",
            "Id": "5151",
            "DateCreated": "2020-09-06T19:26:20.0000000+00:00",
            "PresentationUniqueKey": "a134f3486ede1731bb6fba39aa05c417",
            "Container": "mp4",
            "PremiereDate": "2008-11-26T05:00:00.0000000+00:00",
            "ExternalUrls": [
                {
                    "Name": "IMDb",
                    "Url": "https://www.imdb.com/title/tt1129442"
                },
                {
                    "Name": "TheMovieDb",
                    "Url": "https://www.themoviedb.org/movie/13387"
                },
                {
                    "Name": "TheMovieDb Collection",
                    "Url": "https://www.themoviedb.org/collection/9518"
                },
                {
                    "Name": "Trakt",
                    "Url": "https://trakt.tv/movies/tt1129442"
                }
            ],
            "Path": "/media/movies/Transporter.3.2008.UHD.Dolby.Vision.2160p.BluRay.DVHE.MP4.DD.5.1.H.265-SP4K/Transporter 3 2008 Bluray-2160p.mp4",
            "OfficialRating": "PG-13",
            "Overview": "Frank Martin puts the driving gloves on to deliver Valentina, the kidnapped daughter of a Ukranian government official, from Marseilles to Odessa on the Black Sea. En route, he has to contend with thugs who want to intercept Valentina's safe delivery and not let his personal feelings get in the way of his dangerous objective.",
            "Taglines": [
                "This time, the rules are the same. Except one."
            ],
            "Genres": [
                "Adventure",
                "Action",
                "Crime",
                "Thriller"
            ],
            "CommunityRating": 6.1,
            "RunTimeTicks": 62376640000,
            "ProductionYear": 2008,
            "ProviderIds": {
                "Tmdb": "13387",
                "Imdb": "tt1129442",
                "TmdbCollection": "9518"
            },
            "IsFolder": false,
            "ParentId": "3773",
            "Type": "Movie",
            "Studios": [
                {
                    "Name": "Grive Productions",
                    "Id": 5192
                },
                {
                    "Name": "EuropaCorp",
                    "Id": 5193
                },
                {
                    "Name": "TF1 Films Production",
                    "Id": 5194
                }
            ],
            "GenreItems": [
                {
                    "Name": "Adventure",
                    "Id": 1176
                },
                {
                    "Name": "Action",
                    "Id": 1216
                },
                {
                    "Name": "Crime",
                    "Id": 2444
                },
                {
                    "Name": "Thriller",
                    "Id": 2447
                }
            ],
            "LocalTrailerCount": 0,
            "PrimaryImageAspectRatio": 0.6666666666666666,
            "MediaStreams": [
                {
                    "Codec": "hevc",
                    "CodecTag": "dvhe",
                    "Language": "und",
                    "ColorTransfer": "smpte2084",
                    "ColorPrimaries": "bt2020",
                    "ColorSpace": "bt2020nc",
                    "TimeBase": "1/24000",
                    "CodecTimeBase": "1001/24000",
                    "VideoRange": "HDR",
                    "DisplayTitle": "4K HEVC",
                    "IsInterlaced": false,
                    "BitRate": 47748420,
                    "BitDepth": 10,
                    "RefFrames": 1,
                    "IsDefault": true,
                    "IsForced": false,
                    "Height": 2160,
                    "Width": 3840,
                    "AverageFrameRate": 23.976025,
                    "RealFrameRate": 23.976025,
                    "Profile": "Main 10",
                    "Type": "Video",
                    "AspectRatio": "16:9",
                    "Index": 0,
                    "IsExternal": false,
                    "IsTextSubtitleStream": false,
                    "SupportsExternalStream": false,
                    "Protocol": "File",
                    "PixelFormat": "yuv420p10le",
                    "Level": 153,
                    "IsAnamorphic": false
                },
                {
                    "Codec": "ac3",
                    "CodecTag": "ac-3",
                    "Language": "eng",
                    "TimeBase": "1/48000",
                    "CodecTimeBase": "1/48000",
                    "DisplayTitle": "English AC3 5.1 (Default)",
                    "DisplayLanguage": "English",
                    "IsInterlaced": false,
                    "ChannelLayout": "5.1",
                    "BitRate": 640000,
                    "Channels": 6,
                    "SampleRate": 48000,
                    "IsDefault": true,
                    "IsForced": false,
                    "Type": "Audio",
                    "Index": 1,
                    "IsExternal": false,
                    "IsTextSubtitleStream": false,
                    "SupportsExternalStream": false,
                    "Protocol": "File"
                },
                {
                    "Codec": "mjpeg",
                    "ColorSpace": "bt470bg",
                    "TimeBase": "1/90000",
                    "CodecTimeBase": "0/1",
                    "IsInterlaced": false,
                    "BitDepth": 8,
                    "RefFrames": 1,
                    "IsDefault": false,
                    "IsForced": false,
                    "Height": 360,
                    "Width": 640,
                    "RealFrameRate": 90000,
                    "Profile": "Baseline",
                    "Type": "EmbeddedImage",
                    "AspectRatio": "16:9",
                    "Index": 2,
                    "IsExternal": false,
                    "IsTextSubtitleStream": false,
                    "SupportsExternalStream": false,
                    "Protocol": "File",
                    "PixelFormat": "yuvj420p",
                    "Level": -99,
                    "IsAnamorphic": false
                }
            ],
            "ImageTags": {
                "Primary": "87295f1472b33c5310cb1401996b7a5d",
                "Logo": "943e90042746e4955900b65825eb1260",
                "Thumb": "2a848010eaad650661c77024360e66e6"
            },
            "BackdropImageTags": [
                "664e5e47cb234db504dd775fe339766a"
            ],
            "Chapters": [
                {
                    "StartPositionTicks": 0,
                    "Name": "Chapter 1"
                },
                {
                    "StartPositionTicks": 3000000000,
                    "Name": "Chapter 2"
                },
                {
                    "StartPositionTicks": 6000000000,
                    "Name": "Chapter 3"
                },
                {
                    "StartPositionTicks": 9000000000,
                    "Name": "Chapter 4"
                },
                {
                    "StartPositionTicks": 12000000000,
                    "Name": "Chapter 5"
                },
                {
                    "StartPositionTicks": 15000000000,
                    "Name": "Chapter 6"
                },
                {
                    "StartPositionTicks": 18000000000,
                    "Name": "Chapter 7"
                },
                {
                    "StartPositionTicks": 21000000000,
                    "Name": "Chapter 8"
                },
                {
                    "StartPositionTicks": 24000000000,
                    "Name": "Chapter 9"
                },
                {
                    "StartPositionTicks": 27000000000,
                    "Name": "Chapter 10"
                },
                {
                    "StartPositionTicks": 30000000000,
                    "Name": "Chapter 11"
                },
                {
                    "StartPositionTicks": 33000000000,
                    "Name": "Chapter 12"
                },
                {
                    "StartPositionTicks": 36000000000,
                    "Name": "Chapter 13"
                },
                {
                    "StartPositionTicks": 39000000000,
                    "Name": "Chapter 14"
                },
                {
                    "StartPositionTicks": 42000000000,
                    "Name": "Chapter 15"
                },
                {
                    "StartPositionTicks": 45000000000,
                    "Name": "Chapter 16"
                },
                {
                    "StartPositionTicks": 48000000000,
                    "Name": "Chapter 17"
                },
                {
                    "StartPositionTicks": 51000000000,
                    "Name": "Chapter 18"
                },
                {
                    "StartPositionTicks": 54000000000,
                    "Name": "Chapter 19"
                },
                {
                    "StartPositionTicks": 57000000000,
                    "Name": "Chapter 20"
                },
                {
                    "StartPositionTicks": 60000000000,
                    "Name": "Chapter 21"
                }
            ],
            "MediaType": "Video",
            "Width": 3840,
            "Height": 2160
        },
        "DeviceId": "170beaa2-6489-4664-be2e-5408cd971251",
        "ApplicationVersion": "4.5.2.0",
        "AppIconUrl": "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/chrome.png",
        "SupportedCommands": [
            "MoveUp",
            "MoveDown",
            "MoveLeft",
            "MoveRight",
            "PageUp",
            "PageDown",
            "PreviousLetter",
            "NextLetter",
            "ToggleOsd",
            "ToggleContextMenu",
            "Select",
            "Back",
            "SendKey",
            "SendString",
            "GoHome",
            "GoToSettings",
            "VolumeUp",
            "VolumeDown",
            "Mute",
            "Unmute",
            "ToggleMute",
            "SetVolume",
            "SetAudioStreamIndex",
            "SetSubtitleStreamIndex",
            "RefreshMediaSource",
            "DisplayContent",
            "GoToSearch",
            "DisplayMessage",
            "SetRepeatMode",
            "SetSubtitleOffset",
            "SetPlaybackRate",
            "ChannelUp",
            "ChannelDown",
            "PlayMediaSource",
            "PlayTrailers"
        ],
        "TranscodingInfo": {
            "AudioCodec": "mp3",
            "VideoCodec": "h264",
            "Container": "ts",
            "IsVideoDirect": false,
            "IsAudioDirect": false,
            "Bitrate": 7549747,
            "Framerate": 18,
            "CompletionPercentage": 94.72648735167523,
            "TranscodingPositionTicks": 48707200000,
            "TranscodingStartPositionTicks": 10380000000,
            "Width": 3840,
            "Height": 2160,
            "AudioChannels": 2,
            "TranscodeReasons": [
                "VideoCodecNotSupported",
                "AudioCodecNotSupported"
            ],
            "VideoDecoder": "Automatic software decoder",
            "VideoDecoderIsHardware": false,
            "VideoDecoderMediaType": "HEVC",
            "VideoEncoder": "libx264 Software Encoder",
            "VideoEncoderIsHardware": false,
            "VideoEncoderMediaType": "H.264 (AVC)"
        },
        "SupportsRemoteControl": true
    }
]

 

Dodgexander
Posted

I have it working now, but receive a wall of text in return from the api:

[check.JsonPath]
enabled = true
url = http://192.168.50.149:8096/emby/Sessions?api_key=5e943480810a46428a8d0asc1772b01d&ActiveWithinSeconds =300
jsonpath = [*].NowPlayingItem

Any clue how I can make it neater?
 

Posted

What do you mean by wall of text?

Posted

Sorry what exactly is the end goal?

Dodgexander
Posted
On 05/12/2020 at 08:43, Luke said:

Sorry what exactly is the end goal?

To detect when there's no current session of emby running. Autosuspend supports parsing JSON from the API, so the request made just needs to return something when a session is active and nothing when its not.

At present it works, but when running it returns the entire session API. How can I get it to filter a specific item?

Posted

have you explored the swagger docs? you can filter by i think device id and possibly user id.

Dodgexander
Posted

Yes that's one of the first things I did, but its not clear how you add a filter.

This is an example used for plex with Xpath (XML):

./MediaContainer[@size > 2]

But trying the same with JSON doesn't work.

[check.JsonPath]
enabled = true
url = http://192.168.50.149:8096/emby/Sessions?api_key=5e943485810a46428a8d0acc$
jsonpath = [*].UserId

In return, instead of only the user ID active it returns every parameter in the sessions API.

I am trying to find out how to get the API to respond with current active user, and if no user at all, nothing.

Posted

there is no such thing as one single active user as that will be different for each device/session. You will need to use the DeviceId param to filter the sessions by device.

Dodgexander
Posted
1 hour ago, Luke said:

there is no such thing as one single active user as that will be different for each device/session. You will need to use the DeviceId param to filter the sessions by device.

How can I reduce the output I get from the api?

Following the advice of the author of autosuspend I search for: $.[*].NowPlayingItem the api it returns a massive amount of information when I only need it to return something small. Is there an expression I can use to only return the title of what's playing instead?

For example when I search the api I see:

[Session.SessionInfo{

PlayState PlayerStateInfo{...}

How do I make an expression that will return something more basic than the entire now playing info?

Posted
Quote

How can I reduce the output I get from the api?

Using the DeviceId filter and then you'll only get information about that one device.

Dodgexander
Posted (edited)
15 minutes ago, Luke said:

Using the DeviceId filter and then you'll only get information about that one device.

How can I only the title rather than the entire playback info? I don't use multiple devices so filtering out a single device doesn't really help.

Edited by Dodgexander
Posted

You have to parse the json payload and get what you need from that.

Dodgexander
Posted
3 minutes ago, Luke said:

You have to parse the json payload and get what you need from that.

Okay, so there's no way to receive less overall info from the API when a session is active?

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...