Пример #1
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the Clementine platform."""
    from clementineremote import ClementineRemote
    client = ClementineRemote(config.get(CONF_HOST),
                              config.get(CONF_PORT),
                              config.get(CONF_ACCESS_TOKEN),
                              reconnect=True)

    add_devices([ClementineDevice(client, config[CONF_NAME])])
Пример #2
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Clementine platform."""
    from clementineremote import ClementineRemote
    host = config.get(CONF_HOST)
    port = config.get(CONF_PORT)
    token = config.get(CONF_ACCESS_TOKEN)

    client = ClementineRemote(host, port, token, reconnect=True)

    add_entities([ClementineDevice(client, config[CONF_NAME])])
Пример #3
0
def setup_platform(
    hass: HomeAssistant,
    config: ConfigType,
    add_entities: AddEntitiesCallback,
    discovery_info: DiscoveryInfoType | None = None,
) -> None:
    """Set up the Clementine platform."""

    host = config[CONF_HOST]
    port = config[CONF_PORT]
    token = config.get(CONF_ACCESS_TOKEN)

    client = ClementineRemote(host, port, token, reconnect=True)

    add_entities([ClementineDevice(client, config[CONF_NAME])])
Пример #4
0
# !/usr/bin/python3
# coding=utf-8

import rumps
import threading
from clementineremote import ClementineRemote

clementine = ClementineRemote(host="127.0.0.1", port=5500, auth_code=None, reconnect=True)


class ClemenbarApp(rumps.App):
    def __init__(self):
        super(ClemenbarApp, self).__init__("Clemenbar", "Title")
        tail(self)

    @rumps.clicked("Play/Pause")
    def playPause(self, _):
        clementine.playpause()
        self.title = getTitle()

    @rumps.clicked("Next")
    def next(self, _):
        clementine.next()

    @rumps.clicked("Prev")
    def prev(self, _):
        clementine.previous()

def getTitle():
    defaultTitle = "Clemenbar"
    if clementine is None:
Пример #5
0
def main():

    parser = argparse.ArgumentParser(
        description='Client for the Clementine Music Player remote protocol.')

    parser.add_argument('command', nargs='*', help="command")

    parser.add_argument(
        '-s',
        '--host',
        dest='host',
        action='store',
        type=str,
        default="127.0.0.1",
        help='clementine player remote hostname (default: localhost)')
    parser.add_argument('-p',
                        '--port',
                        dest='port',
                        action='store',
                        type=int,
                        default=5500,
                        help='clementine player remote port (default: 5500)')
    parser.add_argument('-a',
                        '--auth',
                        dest='auth_code',
                        action='store',
                        type=int,
                        default=None,
                        help='auth code (if needed)')
    parser.add_argument('-r',
                        '--reconnect',
                        dest='reconnect',
                        action='store_true',
                        default=False,
                        help='try to reconnect')

    parser.add_argument('--version',
                        action='version',
                        version='%(prog)s ' + __version__)

    parser.prog = "clementine-remote"

    parser.usage = parser.format_usage()[7:] + '''
    Commands:
            status      Show player status
            listen      Listen and show messages (stop with CTRL-C)
            play        Play
            stop        Stop
            pause       Pause
            playpause   Play / Pause
            next        Next track
            previous    Previous track
            set_volume <volume>             Set player volume (0-100)
            playlist_open <playlist>        Open playlist
            insert_urls <playlist> <position> <playnow> <enqueue> <url> ...  Insert urls
            change_song <playlist, index>   Play song in playlist'''

    args = parser.parse_args()

    if len(args.command) == 0:
        parser.print_usage()
        return

    clementine = ClementineRemote(host=args.host,
                                  port=args.port,
                                  auth_code=args.auth_code,
                                  reconnect=args.reconnect)

    for i in range(10):
        if clementine.first_data_sent_complete:
            break
        time.sleep(0.25)

    command = args.command[0].lower()
    if command == "status":
        print(clementine)
        print("Playlists:")
        print("\n".join([str(p) for p in clementine.playlists.values()]))

    elif command == "listen":
        clementine.on_message = print
        try:
            while not clementine._terminated:
                time.sleep(2.0)
        except KeyboardInterrupt as e:
            print("\nInterrupted by user.")

    elif command == "play":
        clementine.play()

    elif command == "pause":
        clementine.pause()

    elif command == "stop":
        clementine.stop()

    elif command == "playpause":
        clementine.playpause()

    elif command == "next":
        clementine.next()

    elif command == "previous":
        clementine.previous()

    elif command == "set_volume":
        volume = int(args.command[1])
        clementine.set_volume(volume)

    elif command == "playlist_open":
        playlist = int(args.command[1])
        clementine.playlist_open(playlist)

    elif command == "change_song":
        clementine.change_song(int(args.command[1]), int(args.command[2]))

    elif command == "insert_urls":  # may need playlist_open args.command[1] first
        clementine.insert_urls(int(args.command[1]), args.command[5:],
                               int(args.command[2]), bool(args.command[3]),
                               bool(args.command[4]))

    else:
        parser.print_usage()
        print("\nUnknown command: %s\n" % command)

    clementine.disconnect()