예제 #1
0
def init_xbmc(ip):
    """ given an ip address, setup the kodi connection """
    utils.log("init_xmbc with ip %s" % ip)
    host = str('http://%s' % ip)
    user = settings.XBMC_USER
    password = settings.XBMC_PASSWD
    xbmc_i = XBMC(get_json_rpc(host), user, password)
    return xbmc_i
예제 #2
0
    def test_execute_ping(self):
        """ Test a call with JSON.Ping """
        # the response does not matters
        responses.add("POST", "http://localhost", "{}")
        url = "http://localhost/"

        x = XBMC(url=url)
        x.execute("JSONRPC.Ping", x=1)

        expectd_body = {
            'id': 0,
            'jsonrpc': '2.0',
            'method': 'JSONRPC.Ping',
            'params': {"x": 1}
        }
        assert responses.calls[0].request.url == 'http://localhost/'
        assert responses.calls[0].request.method == 'POST'
        assert expectd_body == json.loads(
            responses.calls[0].request.body.decode("utf-8"))
예제 #3
0
    def test_execute_ping(self):
        """ Test a call with JSON.Ping """
        # the response does not matters
        responses.add("POST", "http://localhost", "{}")
        url = "http://localhost/"

        x = XBMC(url=url)
        x.execute("JSONRPC.Ping", x=1)

        expectd_body = {
            'id': 0,
            'jsonrpc': '2.0',
            'method': 'JSONRPC.Ping',
            'params': {
                "x": 1
            }
        }
        assert responses.calls[0].request.url == 'http://localhost/'
        assert responses.calls[0].request.method == 'POST'
        assert expectd_body == json.loads(
            responses.calls[0].request.body.decode("utf-8"))
예제 #4
0
 def initializeXbmc(self):
     host = self.getHost()
     user = self.getUser()
     password = self.getPassword()
     if not host:
         raise Exception(
             "No host found. Have you configured the default config file %s ?"
             % (self.getDefaultConfig()))
     if not user:
         raise Exception(
             "No user found. Have you configured the default config file %s ?"
             % (self.getDefaultConfig()))
     self.xbmc = XBMC(self.getJsonRpc(host), user, password)
예제 #5
0
def handle(self, text, mic, profile):
    """
        Responds to user-input, typically speech text, by relaying the
        meaning of life.

        Arguments:
        text -- user-input, typically transcribed speech
        mic -- used to interact with the user (for both input and output)
        profile -- contains information related to the user (e.g., phone
                   number)
    """
    xbmc = XBMC("http://192.168.42.142/jsonrpc", "darthtoker", "Garfield76")
    xbmc.Player.PlayPause({"playerid": 1})
예제 #6
0
 def pause_kodi(self):
     log.debug("Pausing Kodi")
     kodi = XBMC("http://192.168.1.69:8080/jsonrpc")
     playerid_result = kodi.Player.GetActivePlayers()['result']
     if playerid_result:
         playerid = playerid_result[0]['playerid']
     else:
         return
     speed = kodi.Player.GetProperties({
         'playerid': playerid,
         'properties': ['speed']
     })['result']['speed']
     if speed != 0:
         kodi.Player.PlayPause({'playerid': playerid})
예제 #7
0
def main(host, login, passwd):
    # Initialisation de la fenêtre d'affichage
    root = Tk()
    global xbmc
    xbmc = XBMC("http://" + host + "/jsonrpc", login, passwd)

    try:
        xbmc.JSONRPC.Ping()
        c = 0
    except:
        c = 1

    root.title('Remote Control for Kodi/XBMC')
    root.geometry('600x336')
    if c == 1:
        running = Label(root, text="Can't find the MediaCenter.")
        running.pack()
    else:
        xbmc.GUI.ShowNotification(title="Kodi-Pymote",
                                  message="Connection established")
        running = Label(root, text="Pymote is running ...")
        running.pack()
        # Boucle d'évènements
        root.bind("<Up>", goUp)
        root.bind("<Down>", goDown)
        root.bind("<Right>", goRight)
        root.bind("<Left>", goLeft)
        root.bind("<Escape>", goHome)
        root.bind("<Return>", Select)
        root.bind("<BackSpace>", goBack)
        root.bind("c", ContextMenu)
        root.bind("<space>", Play_Pause)
        root.bind("m", Mute)
        root.bind("s", Stop)
        root.bind('f', Fullscreen)
        root.bind("<Tab>", ShowOSD)

    root.mainloop()
예제 #8
0
    def test_default(self):
        """Tests XBMCJsonTransport default values"""

        url = "http://localhost/"
        x = XBMC(url=url)
        assert isinstance(x.Addons, Addons)

        assert isinstance(x.Application, Application)
        assert isinstance(x.AudioLibrary, AudioLibrary)

        assert isinstance(x.Favourites, Favourites)
        assert isinstance(x.Files, Files)
        assert isinstance(x.GUI, GUI)
        assert isinstance(x.Input, Input)
        assert isinstance(x.JSONRPC, JSONRPC)

        assert isinstance(x.Playlist, Playlist)
        assert isinstance(x.Player, Player)
        assert isinstance(x.PVR, PVR)

        assert isinstance(x.Settings, Settings)
        assert isinstance(x.System, System)
        assert isinstance(x.VideoLibrary, VideoLibrary)
        assert isinstance(x.xbmc, xbmc)
예제 #9
0
 def connectKodi(self, kodiIp):
     return XBMC("http://" + kodiIp + ":" + str(conf.PORT_HTTP_KODI) + "/jsonrpc")  
예제 #10
0
def play_bd(bdmv_index_path):
    play_target = ""
    xbmc_play_path = ""
    player_id = None

    xbmc = XBMC(REQUEST_URL)
    result = xbmc.Player.GetActivePlayers().get("result")
    #print "Active Players: ", result
    if result and len(result) > 0:
        player_id = result[0].get("playerid")
        if player_id != None:
            result = xbmc.Player.GetItem({"properties": ["file"], "playerid": player_id}).get("result")
            #print "Got item result: ", result
            if result and len(result) > 0:
                item = result.get("item")
                if item:
                    file = item.get("file")
                    if file:
                        #print "Found file: ", file
                        xbmc_play_path = file
    if not xbmc_play_path:
        print "Did not get currently playing file path from JSON-RPC."

    if bdmv_index_path.endswith("index.bdmv") and xbmc_play_path.endswith("index.bdmv"):
        bdmv_root_path = bdmv_index_path[:-10]
        xbmc_play_root_path = xbmc_play_path[:-10]
        #print "Found Blu-ray in path", bdmv_root_path

        srt_list = find_srt(bdmv_root_path)
        playlist_txt = check_playlist_txt(bdmv_root_path)

        # Playlist path change assumes that the internal path from Kodi uses / as directory separator. Works at least for smb:// sources.
        if playlist_txt:
            #print "Found playlist", playlist_txt, "from playlist.txt"
            play_target = xbmc_play_root_path + "PLAYLIST/" + playlist_txt + ".mpls"
        elif len(srt_list) > 0:
            #print "Found SRTs", srt_list
            play_target = xbmc_play_root_path + "PLAYLIST/" + srt_list[0] + ".mpls"
        else:
            print "Did not find overrides, proceeding with index.bdmv"
            play_target = ""

    pid = player_id if player_id != None else PLAYER_VIDEO
    
    if play_target:
        print "Found play target: ", play_target
        stop_playback(xbmc, pid)
        result = xbmc.Player.Open({"item": {"file": play_target}})
        #print "Commanded playback with result: ", result
    elif xbmc_play_path:
        print "Using bdmv ", xbmc_play_path
        stop_playback(xbmc, pid)
        result = xbmc.Player.GetPlayers({"media": "video"}).get("result")
        #print "Found players: ", result
        if result and len(result) > 0:
            dsplayer_id = dvdplayer_id = None
            for player in result:
                #print "Player: ", player
                if player.get("name") == "DSPlayer":
                    dsplayer_id = player.get("playercoreid")
                elif player.get("name") == "DVDPlayer":
                    dvdplayer_id = player.get("playercoreid")
            if dsplayer_id is not None or dvdplayer_id is not None:
                #print "Got internal player id, continuing"
                pid = dsplayer_id if dsplayer_id is not None else dvdplayer_id
                result = xbmc.Player.Open({"item": {"file": xbmc_play_path}, "options": {"playercoreid": pid}})
                #print "Open returned result", result
            else:
                print "Didn't find an internal player from Kodi JSON-RPC."
    else:
        print "Failed to find Kodi internal Blu-ray path for playback."
예제 #11
0
def addToPlayLog(row):
    with open('/media/pi/storybox/playlog.csv', 'a') as f:
        writer = csv.writer(f)
        writer.writerow(row)


def maxVolume():
    xbmc.Application.SetMute({"mute": False})
    xbmc.Application.SetVolume({"volume": 100})


time.sleep(7)
checkPlayLog()

xbmc = XBMC("http://localhost:8080/jsonrpc", "kodi", "kodi")
print xbmc.JSONRPC.Ping()
maxVolume()

lastRecorded = datetime.now() - timedelta(minutes=2)


def enterLog(opts={}):
    xbmc.Input.Select({})
    maxVolume()
    time.sleep(1.5)
    active = xbmc.Player.GetActivePlayers()
    if (len(active['result']) != 0):
        minAgo = datetime.now() - timedelta(minutes=1)
        if lastRecorded < minAgo:
            lastRecorded = datetime.now()
예제 #12
0
파일: xbmc.py 프로젝트: okalinsk/SmartHome
 def __init__(self, user, password):
     self.xbmc = XBMC("http://localhost:8052/jsonrpc", user, password)
예제 #13
0
 def load_config(self):
     """Create the .xbmc client."""
     self.xbmc = XBMC(self.config['HOST'], self.config['LOGIN'],
                      self.config['PASSWORD'])
예제 #14
0
 def __init__(self, _url):
     Thread.__init__(self)
     self.kodi = XBMC("%s/jsonrpc" % _url)
     self.playing = False
예제 #15
0
파일: tests.py 프로젝트: jbottel/TARS
 def setUp(self):
     TARS.app.config['TESTING'] = True
     self.xbmc = XBMC(settings.JSONRPC_URI + '/jsonrpc')
     self.c = TARS.app.test_client()
예제 #16
0
from xbmcjson import XBMC
from bottle import route, run, template, redirect, static_file, request
import os

#TODO
#start on correct ip (pass as argument?)
#add head info to templates

#config
hostname = "0.0.0.0"
hostport = 8000
path_for_files = ""
#endconfig

xbmc = XBMC("http://192.168.0.5/jsonrpc", "xbmc", "xbmc")


def get_playlistid():
    player = xbmc.Player.GetActivePlayers()
    if len(player['result']) > 0:
        playlist_data = xbmc.Player.GetProperties({
            "playerid": 0,
            "properties": ["playlistid"]
        })
        if len(playlist_data['result']
               ) > 0 and "playlistid" in playlist_data['result'].keys():
            return playlist_data['result']['playlistid']

    return -1

예제 #17
0
 def test1(self):
     xbmc = XBMC("http://192.168.1.100:8080/jsonrpc")
     audio = xbmc.AudioLibrary.GetSongs()
     print(audio)
예제 #18
0
 def login_xbmc(self, ip):
     # Login with default xbmc/xbmc credential
     url = 'http://' + ip + '/jsonrpc'
     xbmc = XBMC(url)
     return xbmc
예제 #19
0
 def __init__(self, args):
     baseRFIDServer.__init__(self, args)
     self.name = 'kodi'
     self.kodi = XBMC("%s/jsonrpc" % args.kodiurl)
예제 #20
0
#!/bin/env/python

from xbmcjson import XBMC, PLAYER_VIDEO

if __name__ == "__main__":
    xbmc = XBMC("http://YOURHOST/jsonrpc")
    # JSON RPC
    # Ping
    print xbmc.JSONRPC.Ping()

    # Gui
    xbmc.GUI.ActivateWindow({"window": "home"})
    xbmc.GUI.ActivateWindow({"window": "weather"})
    # Show a notification
    xbmc.GUI.ShowNotification({"title": "Title", "message": "Hello notif"})
    # Application
    xbmc.Application.SetMute({"mute": True})
    xbmc.Application.SetMute({"mute": False})
    # Video library
    xbmc.VideoLibrary.Scan()
    xbmc.VideoLibrary.Clean()
    # Query the video library
    print xbmc.VideoLibrary.GetTVShows(
        {
            "filter": {
                "field": "playcount",
                "operator": "is",
                "value": "0"
            },
            "limits": {
                "start": 0,
예제 #21
0
from flask import Flask
from flask import render_template
from flask import jsonify
from flask import request
from flask import redirect
import random
from xbmcjson import XBMC
app = Flask(__name__)
app.config.from_object('settings')
xbmc = XBMC(app.config["JSONRPC_URI"] + "/jsonrpc")


@app.route('/')
def index():
    """Compile all of the items necessary on the front page, including:
    - List of recently added episodes
    - List of recently added movies
    - Lists of the video and audio playlist items

    Return a rendered template.
    """

    try:
        recently_added_episodes = xbmc.VideoLibrary.GetRecentlyAddedEpisodes({
            "properties": [
                "showtitle", "tvshowid", "title", "episode", "season",
                "firstaired", "plot", "thumbnail"
            ],
            "limits": {
                "end": 5
            }
예제 #22
0
 def __init__(self, api_url):
     self.api_url = api_url
     XBMC.__init__(self, api_url)
예제 #23
0
from xbmcjson import XBMC, PLAYER_VIDEO
#Login with default xbmc/xbmc credentials
xbmc = XBMC("http://YOURHOST/jsonrpc")

#Login with custom credentials
xbmc = XBMC("http://192.168.42.142/jsonrpc", "darthtoker", "Garfield76")

#print xbmc.JSONRPC.Ping()

#xbmc.Input.Info()
#xbmc.GUI.ActivateWindow(window="home")
xbmc.GUI.ShowNotification({"title": "love you", "message": "I love candy"})
예제 #24
0
 def _create_connection(self, host, *args, **kwargs):
     self._kodi = XBMC(host)