Exemplo n.º 1
0
def stop_player(type: str) -> State:

    _activePlayers = get_active_players_with_playlist(type)
    if type not in _activePlayers:
        return None

    json_rpc("Player.Stop", params=[_activePlayers[type].playerId])
    xbmc.sleep(500)

    return _activePlayers[type]
Exemplo n.º 2
0
def get_active_players() -> 'dict[str,int]':

    _json_active_players = json_rpc("Player.GetActivePlayers")
    active_players = dict()
    for ap in _json_active_players:
        active_players[ap["type"]] = ap["playerid"]

    return active_players
Exemplo n.º 3
0
def get_volume(or_default=100) -> int:

    try:
        _result = json_rpc("Application.GetProperties",
                           {"properties": ["volume"]})
        return _result["volume"]

    except:
        return or_default
Exemplo n.º 4
0
    def _get_playlist(playListID: int) -> dict:

        _params = {
            "playlistid": playListID,
            "properties": [
                "file"
            ],
            "limits": {
                "start": 0
            }
        }
        return json_rpc("Playlist.GetItems", _params)
Exemplo n.º 5
0
def get_pvr_channel_path(type: str, channelno: str) -> str:

    try:
        channelno = int(channelno)
        _result = json_rpc("PVR.GetChannelGroups", {"channeltype": type})
        channelGroupAll = _result["channelgroups"][0]["label"]

        _result = json_rpc("PVR.GetClients")
        pvrClients = _result["clients"]

        _result = json_rpc(
            "PVR.GetChannels", {
                "channelgroupid": "all%s" % type,
                "properties": ["uniqueid", "clientid", "channelnumber"]
            })
        channel = next(
            filter(lambda c: c["channelnumber"] == channelno,
                   _result["channels"]), None)

        if not channel:
            return None

        pvrClient = list(
            filter(
                lambda _c: _c["supportsepg"] == True and _c["clientid"] ==
                channel["clientid"], pvrClients))[0]

        if channelGroupAll and pvrClient and channel:
            return _PLAY_PVR_URL_PATTERN % (type, parse.quote(channelGroupAll),
                                            pvrClient["addonid"],
                                            channel["uniqueid"])

    except:
        pass

    return None
Exemplo n.º 6
0
    def _get_player_properties(playerId: int) -> dict:

        _params = {
            "playerid": playerId,
            "properties": [
                "type",
                "time",
                "playlistid",
                "position",
                "repeat",
                "shuffled",
                "speed"
            ]
        }
        return json_rpc("Player.GetProperties", _params)
Exemplo n.º 7
0
def set_powermanagement_displaysoff(value: int) -> None:

    json_rpc("Settings.SetSettingValue", {
        "setting": "powermanagement.displaysoff",
        "value": value
    })
Exemplo n.º 8
0
def get_slideshow_staytime() -> int:

    _result = json_rpc("Settings.GetSettingValue", params={
        "setting": "slideshow.staytime"})
    return _result["value"]
Exemplo n.º 9
0
    def _get_player_item(playListID: int) -> dict:

        _params = [playListID, ["file"]]
        return json_rpc("Player.GetItem", _params)