Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/python3
- import sys
- try:
- from kodipydent import Kodi
- except ModuleNotFoundError:
- print("kodipydent is required. pip3 install kodipydent\n")
- sys.exit(1)
- # Just a Kodi remote
- HOSTNAME = 'grapefruit'
- PORT = 8080
- USERNAME = 'kodi'
- PASSWORD = None
- def main():
- help = "Usage: kontrol.py <command>\n" \
- "- : decrease volume\n" \
- "+ : increase volume\n" \
- "m/mute : mute\n" \
- "p/play : play/pause\n" \
- "s/stop : stop playback\n"\
- _kodi = Kodi(HOSTNAME, username=USERNAME, password=PASSWORD)
- _mute = _kodi.Application.GetProperties(['muted'])['result']['muted']
- _volume = _kodi.Application.GetProperties(['volume'])['result']['volume']
- _playerid = _kodi.Player.GetActivePlayers()['result'][0]['playerid']
- arg = None
- try:
- arg = sys.argv[1]
- except IndexError:
- print(help)
- else:
- if arg == '-':
- _kodi.Application.SetVolume(int(_volume - 5))
- elif arg == '+':
- _kodi.Application.SetVolume(int(_volume + 5))
- elif arg == 'm' or arg == 'mute':
- if _mute:
- _kodi.Application.SetMute(False)
- else:
- _kodi.Application.SetMute(True)
- elif arg == 'p' or arg == 'play':
- _kodi.Player.PlayPause(_playerid)
- elif arg == 's' or arg == 'stop':
- _kodi.Player.Stop(_playerid)
- else:
- print("Command doesn't exist")
- main()
Add Comment
Please, Sign In to add comment