Ejemplo n.º 1
0
def main():
    "Entry point for the CLI DBus interface."
    args = docopt(__doc__, version="0.2")
    util.init_logger(args["--log"], args["-v"], args["--quiet"])
    dbus = DBusClient()

    if args["toggle"]:
        dbus.playpause()
    elif args["next"]:
        dbus.next()
    elif args["prev"]:
        dbus.prev()
    elif args["play"]:
        dbus.play()
    elif args["pause"]:
        dbus.pause()
    elif args["stop"]:
        dbus.stop()

    if args["openuri"]:
        dbus.open_uri(args["<uri>"])
    elif args["seek"]:
        dbus.seek(args["<secs>"])
    elif args["setpos"]:
        dbus.set_pos(args["<pos>"])

    if args["title"]:
        print(dbus.get_song_title())
    elif args["artist"]:
        print(dbus.get_song_artist())
    elif args["status"]:
        print(dbus.get_song_status())
    elif args["all"]:
        dbus.print_info()
    elif args["get"]:
        length = dbus.get_song_length()
        m, s = divmod(length, 60)
        if args["length"]:
            print("{}m{}s ({})".format(m, s, length))
        else:
            rating = dbus.get_property("Metadata")["xesam:autoRating"]
            artist = dbus.get_song_artist()
            title = dbus.get_song_title()
            album = dbus.get_song_album()
            state = dbus.get_song_status()
            print("{} - {} ({}), {}m{}s, {} ({})".format(artist, title, album,
                                                         m, s, rating, state))
Ejemplo n.º 2
0
def main():
    """Entry point for the CLI DBus interface."""
    args = docopt(__doc__, version="0.3")
    util.init_logger(args["--log"], args["-v"], args["--quiet"])
    dbus = DBusClient()

    if args["toggle"]:
        dbus.playpause()
    elif args["next"]:
        dbus.next()
    elif args["prev"]:
        dbus.prev()
    elif args["play"]:
        dbus.play()
    elif args["pause"]:
        dbus.pause()
    elif args["stop"]:
        dbus.stop()

    if args["openuri"]:
        dbus.open_uri(args["<uri>"])
    elif args["seek"]:
        dbus.seek(args["<secs>"])
    elif args["setpos"]:
        dbus.set_pos(args["<pos>"])

    if args["title"]:
        print(dbus.get_song_title())
    elif args["artist"]:
        print(dbus.get_song_artist())
    elif args["status"]:
        print(dbus.get_song_status())
    elif args["all"]:
        dbus.print_info()
    elif args["get"]:
        length = dbus.get_song_length()
        m, s = divmod(length, 60)
        if args["length"]:
            print("{}m{}s ({})".format(m, s, length))
        else:
            rating = dbus.get_property("Metadata")["xesam:autoRating"]
            artist = dbus.get_song_artist()
            title = dbus.get_song_title()
            album = dbus.get_song_album()
            state = dbus.get_song_status()
            print("{} - {} ({}), {}m{}s, {} ({})".format(
                artist, title, album, m, s, rating, state))
Ejemplo n.º 3
0
def main():
    """Entry point for the CLI DBus interface."""
    args = util.docopt(__doc__, version="0.4.1")
    util.init_logger(args["--log"], args["-v"], args["--quiet"])
    dbus_client = DBusClient()

    args_mapper = {
        "setpos": wrap_action(dbus_client.set_position, args["<pos>"]),
        "openuri": wrap_action(dbus_client.open_uri, args["<uri>"]),
        "seek": wrap_action(dbus_client.seek, args["<secs>"]),
        "toggle": wrap_action(dbus_client.playpause),
        "next": wrap_action(dbus_client.next),
        "prev": wrap_action(dbus_client.prev),
        "play": wrap_action(dbus_client.play),
        "pause": wrap_action(dbus_client.pause),
        "stop": wrap_action(dbus_client.pause),
        "song": wrap_action(dbus_client.get_song),
        "album": wrap_action(dbus_client.get_song_album),
        "artist": wrap_action(dbus_client.get_song_artist),
        "length": wrap_action(dbus_client.get_song_length),
        "title": wrap_action(dbus_client.get_song_title),
        "status": wrap_action(dbus_client.get_song_status),
        "all": wrap_action(print_all, dbus_client),
    }

    for arg_key, arg_value in args.items():
        action_info = args_mapper.get(arg_key, None)
        if arg_value and action_info:
            action = action_info.get("action", None)
            if action:
                action_args = action_info.get("args", None)
                result = action(*action_args) if action_args else action()
                if result:
                    print(result)
                sys.exit()

    # Since get can have follow-up actions it has to be handled last and separately.
    if args.get("get", None):
        print_song(dbus_client)
Ejemplo n.º 4
0
def main():
    """Entry point for the CLI DBus interface."""
    args = util.docopt(__doc__, version="0.4.1")
    util.init_logger(args["--log"], args["-v"], args["--quiet"])
    dbus_client = DBusClient()

    args_mapper = {
        "setpos": wrap_action(dbus_client.set_position, args["<pos>"]),
        "openuri": wrap_action(dbus_client.open_uri, args["<uri>"]),
        "seek": wrap_action(dbus_client.seek, args["<secs>"]),
        "toggle": wrap_action(dbus_client.playpause),
        "next": wrap_action(dbus_client.next),
        "prev": wrap_action(dbus_client.prev),
        "play": wrap_action(dbus_client.play),
        "pause": wrap_action(dbus_client.pause),
        "stop": wrap_action(dbus_client.pause),
        "song": wrap_action(dbus_client.get_song),
        "album": wrap_action(dbus_client.get_song_album),
        "artist": wrap_action(dbus_client.get_song_artist),
        "length": wrap_action(dbus_client.get_song_length),
        "title": wrap_action(dbus_client.get_song_title),
        "status": wrap_action(dbus_client.get_song_status),
        "all": wrap_action(print_all, dbus_client),
    }

    for arg_key, arg_value in args.items():
        action_info = args_mapper.get(arg_key, None)
        if arg_value and action_info:
            action = action_info.get("action", None)
            if action:
                action_args = action_info.get("args", None)
                result = action(*action_args) if action_args else action()
                if result:
                    print(result)
                sys.exit()

    # Since get can have follow-up actions it has to be handled last and separately.
    if args.get("get", None):
        print_song(dbus_client)