Adding to XBMC Favourites
#1
We have an addon which is basically an EPG plus live streams, we have added "Add To Favourites" functionality so that the streams themselves can be added to the XBMC favourites list.

At the moment to do this we actually load in the favourites.xml file, add our stuff and then resave the file

I'm sure there must be a more "offical" way of doing this via an XBMC builtin function or something.

Any help would be appreciated.
Reply
#2
PR2600 is in the works
Reply
#3
From Github it looks like this was implemented, but is it documented anywhere as I would like to use it now
Reply
#4
Didn't know we could access favourites via JSON. Just used it to retrieve the user favourites - so much nicer than parsing the favourites.xml file manually.

I used JSONRPC.Introspect() to get the details of how to use it. The relevant bits are below.

Code:
"Favourites.AddFavourite": {
    "description": "Add a favourite with the given details",
    "params": [
        {
            "name": "title",
            "required": true,
            "type": "string"
        },
        {
            "$ref": "Favourite.Type",
            "name": "type",
            "required": true
        },
        {
            "$ref": "Optional.String",
            "default": null,
            "description": "Required for media and script favourites types",
            "name": "path"
        },
        {
            "$ref": "Optional.String",
            "default": null,
            "description": "Required for window favourite type",
            "name": "window"
        },
        {
            "$ref": "Optional.String",
            "default": null,
            "name": "windowparameter"
        },
        {
            "$ref": "Optional.String",
            "default": null,
            "name": "thumbnail"
        }
    ],
    "returns": {
        "type": "string"
    },
    "type": "method"
},
"Favourites.GetFavourites": {
    "description": "Retrieve all favourites",
    "params": [
        {
            "default": null,
            "name": "type",
            "type": [
                {
                    "type": "null"
                },
                {
                    "$ref": "Favourite.Type"
                }
            ]
        },
        {
            "$ref": "Favourite.Fields.Favourite",
            "name": "properties"
        }
    ],
    "returns": {
        "properties": {
            "favourites": {
                "items": {
                    "$ref": "Favourite.Details.Favourite"
                },
                "type": "array"
            },
            "limits": {
                "$ref": "List.LimitsReturned",
                "required": true
            }
        },
        "type": "object"
    },
    "type": "method"
},
"Favourite.Details.Favourite": {
    "additionalProperties": false,
    "id": "Favourite.Details.Favourite",
    "properties": {
        "path": {
            "default": "",
            "type": "string"
        },
        "thumbnail": {
            "default": "",
            "type": "string"
        },
        "title": {
            "required": true,
            "type": "string"
        },
        "type": {
            "$ref": "Favourite.Type",
            "required": true
        },
        "window": {
            "default": "",
            "type": "string"
        },
        "windowparameter": {
            "default": "",
            "type": "string"
        }
    },
    "type": "object"
},
"Favourite.Fields.Favourite": {
    "extends": "Item.Fields.Base",
    "id": "Favourite.Fields.Favourite",
    "items": {
        "enums": [
            "window",
            "windowparameter",
            "thumbnail",
            "path"
        ],
        "type": "string"
    }
},
"Favourite.Type": {
    "default": "media",
    "enums": [
        "media",
        "window",
        "script",
        "unknown"
    ],
    "id": "Favourite.Type",
    "type": "string"
}

Hope that's useful to you.
Reply
#5
@Unfledged

Thanks for that, finally got round to trying it out and turns it there may be a bug.

If I do this:

Code:
name  = 'name_test'
thumb = 'thumb_test'
cmd   = 'cmd_test,param'

result = json.loads(xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "Favourites.AddFavourite", "params": {"title":"%s", "type":"script", "path":"%s", "thumbnail":"%s"}, "id": 1}' % (name, cmd, thumb)))

result shows that it was successful, but it gives me this in the favourites.xml file:

Code:
<favourite name="name_test" thumb="thumb_test">RunScript(&quot;cmd_test,param&quot;)</favourite>

Which doesn't work due to the &quot;

Without them it works fine, i.e.

Code:
<favourite name="name_test" thumb="thumb_test">RunScript(cmd_test,param)</favourite>

Might have to raise it on trac
Reply

Logout Mark Read Team Forum Stats Members Help
Adding to XBMC Favourites0