Kodi Community Forum
Keeping track of played state? - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: Keeping track of played state? (/showthread.php?tid=179252)



Keeping track of played state? - User 191275 - 2013-11-30

Is there an easy way to keep track of the played state for remote videos in a Python add-on? I noticed that Frodo keeps track of how far you've gotten in a given video, but I'm not sure if there's a way to query that from Python. It seems like I'd need to do something to figure out if a video is 1) unplayed, 2) in progress, or 3) played before adding the list item for it. Any ideas, or even better, some code from an add-on that already does this?


RE: Keeping track of played state? - Karnagious - 2013-11-30

You need to familiarize yourself with the XBMC databases.

http://wiki.xbmc.org/index.php?title=XBMC_databases#Accessing_the_Databases_with_XBMC_Python


RE: Keeping track of played state? - User 191275 - 2013-11-30

Should this work? I keep getting an "Invalid params." error.

Code:
query = xbmc.executeJSONRPC(simplejson.dumps(
        { "jsonrpc": "2.0",
          "method": "Files.GetFileDetails",
          "params": {
                "file": remote_url, # This is the full URL to a file on the web
                "media": "video",
                "properties": ["playcount"],
                },
          "id": 1
          }
        ))

I looked in the videos database and there's an entry for the URL I'm querying.

EDIT: The logs show this, though:
Code:
22:04:09 T:140503211308800   ERROR: GetDirectory - Unable to get http directory
22:04:09 T:140503211308800   ERROR: GetDirectory - Error getting <<remote_url's parent dir>>



RE: Keeping track of played state? - Karnagious - 2013-11-30

ah REMOTE videos. Didnt see that the first time.


RE: Keeping track of played state? - User 191275 - 2013-12-01

It looks like this line might be the issue: https://github.com/xbmc/xbmc/blob/12.2-Frodo/xbmc/interfaces/json-rpc/FileOperations.cpp#L212

EDIT: To elaborate, File.GetFileDetails tries to ensure that it can get the parent directory, but that almost never works for files on the web. Is this a bug? It'd be super great if this worked, since then add-ons that play web video could easily show played states. It's disheartening that all the info is in the database, but I can't use JSON-RPC to grab it (and my understanding is that add-ons can't directly query the DB if they want to be allowed in the official repo).


RE: Keeping track of played state? - User 191275 - 2013-12-02

Since this seems like an issue with XBMC, would it make sense to move this to the "Feature Suggestions" forum?