media.kodi
media.kodi
- class platypush.plugins.media.kodi.MediaKodiPlugin(host, http_port=8080, websocket_port=9090, username=None, password=None, **kwargs)[source]
Plugin to interact with a Kodi media player instance
Requires:
kodi-json (
pip install kodi-json
)
- __init__(host, http_port=8080, websocket_port=9090, username=None, password=None, **kwargs)[source]
- Parameters:
host (str) – Kodi host name or IP
http_port (int) – Kodi JSON RPC web port. Remember to enable “Allow remote control via HTTP” in Kodi service settings -> advanced configuration and “Allow remote control from applications” on this system and, optionally, on other systems if the Kodi server is on another machine
websocket_port (int) – Kodi JSON RPC websocket port, used to receive player events
username (str) – Kodi username (optional)
password (str) – Kodi password (optional)
- back(offset=30, player_id=None, *args, **kwargs)[source]
Move the player execution backward by delta_seconds
- Parameters:
offset (float) – Backward seek duration (default: 30 seconds)
player_id – ID of the target player (default: configured/current player).
- download(url, filename=None, directory=None)
Download a media URL
- Parameters:
url – Media URL
filename – Media filename (default: URL filename)
directory – Destination directory (default: download_dir)
- Returns:
The absolute path to the downloaded file
- forward(offset=30, player_id=None, *args, **kwargs)[source]
Move the player execution forward by delta_seconds
- Parameters:
offset (float) – Forward seek duration (default: 30 seconds)
player_id – ID of the target player (default: configured/current player).
- get_media_file_duration(filename)
Get the duration of a media file in seconds. Requires ffmpeg
- next()
Play the next item in the queue
- play(resource, *args, **kwargs)[source]
Open and play the specified file or URL
- Parameters:
resource – URL or path to the media to be played
- search(query, types=None, queue_results=False, autoplay=False, search_timeout=60)
Perform a video search.
- Parameters:
query (str) – Query string, video name or partial name
types (list) – Video types to search (default:
["youtube", "file", "torrent"]
)queue_results (bool) – Append the results to the current playing queue (default: False)
autoplay (bool) – Play the first result of the search (default: False)
search_timeout (float) – Search timeout (default: 60 seconds)
- seek(position, player_id=None, *args, **kwargs)[source]
Move to the specified time position in seconds
- Parameters:
position (float) – Seek time in seconds
player_id – ID of the target player (default: configured/current player).
- send_text(text, *args, **kwargs)[source]
Simulate a send_text input event
- Parameters:
text (str) – Text to send
- set_position(position, player_id=None, *args, **kwargs)[source]
Move to the specified time position in seconds
- Parameters:
position (float) – Seek time in seconds
player_id – ID of the target player (default: configured/current player).
- set_volume(volume, *args, **kwargs)[source]
Set the application volume
- Parameters:
volume (int) – Volume to set between 0 and 100
- start_streaming(media, subtitles=None, download=False)
Starts streaming local media over the specified HTTP port. The stream will be available to HTTP clients on http://{this-ip}:{http_backend_port}/media/<media_id>
- Parameters:
- Returns:
dict containing the streaming URL.Example:
{ "id": "0123456abcdef.mp4", "source": "file:///mnt/media/movies/movie.mp4", "mime_type": "video/mp4", "url": "http://192.168.1.2:8008/media/0123456abcdef.mp4" }