JSON call to items in Videolibrary
#1
Hi all,

I've got basic JSON calls working and get player state, etc. I'm now trying to retrieve items from the VideoLibrary.

Specifically I want to find items that have been marked as played. Previously I used to do this direct in MySQL storage engine, so I could query table "MyVideos119" (or whatever number) and the "files" table asking for anything with a greater than 0 playCount.
I'm trying to replicate this with JSON calls but strugging.

First question, should I be using api to VideoLibrary or Files?

I think using Files is what I need. By querying the Files.GetDirectory I get the files in that particular library/location:

/usr/bin/curl -v --user test:test --header 'Content-Type: application/json' --data-binary '{"jsonrpc":"2.0","id":1,"method":"Files.GetDirectory","params":{"directory": "/RecordedTV/"}}' http://192.168.XX.1:8080/jsonrpc

As that returns:
{"file":"/RecordedTV/BBC-One-NE&C-HD-Eat-Well-for-Less_-2022-06-23-.ts","filetype":"file","label":"BBC-One-NE&C-HD-Eat-Well-for-Less_-2022-06-23-.ts","type":"unknown"}

But I'm missing how that then links up with the playcount and how to retrieve it, can anyone offer any pointers to where I can fetch that part?

Thanks!
Andy - http://twitter.com/andyb2000 http://www.thebmwz3.co.uk/
HTS Tvheadend development (via http://github.com/andyb2000) On Ubuntu with ST STV0299 DVB-S2, Conexant CX24116/CX24118, Philips TDA10046H DVB-T (Freesat and Freeview in the UK)

XBMC via OpenElec on Dell XPS210
Reply
#2
Hi,

you can ask for the playcount in your JSON command like this:

{"jsonrpc":"2.0","id":1,"method":"Files.GetDirectory","params":{"directory": "/RecordedTV/", "properties":["playcount"]}}

Then you should receive the playcount as part of the result for each item.
Reply
#3
Hi,
That's great, thank you for the help, one slight tweak for anyone coming here looking for similar, I needed to also specify the media type to allow the "properties" to be honoured.

So:
Quote:/usr/bin/curl -v --user test:test --header 'Content-Type: application/json' --data-binary '{"jsonrpc":"2.0","id":1,"method":"Files.GetDirectory","params":{"directory": "/RecordedTV/", "media": "video", "properties": ["playcount","lastplayed","file"]}}' http://192.168.X.1:8080/jsonrpc
 
Which then returns (one example):
Quote:{"file":"/RecordedTV/Channel-4-HD-New_-Food-Unwrapped's-Sweet-Treat-2022-06-20-.ts","filetype":"file","label":"Channel-4-HD-New_-Food-Unwrapped's-Sweet-Treat-2022-06-20-.ts","lastplayed":"2022-07-22 20:00:16","playcount":1,"type":"unknown"}
Which is perfect for what I want.

Thank you Smile
Andy - http://twitter.com/andyb2000 http://www.thebmwz3.co.uk/
HTS Tvheadend development (via http://github.com/andyb2000) On Ubuntu with ST STV0299 DVB-S2, Conexant CX24116/CX24118, Philips TDA10046H DVB-T (Freesat and Freeview in the UK)

XBMC via OpenElec on Dell XPS210
Reply

Logout Mark Read Team Forum Stats Members Help
JSON call to items in Videolibrary0