Ejemplo n.º 1
0
def main():
    argparser = argparse.ArgumentParser(add_help=False)
    subparsers = argparser.add_subparsers()

    listsongs_p = subparsers.add_parser("ls")
    listsongs_p.add_argument("collection", nargs="?")
    listsongs_p.add_argument("-f", nargs="?", const="")
    listsongs_p.add_argument("--p", action="store_true")
    listsongs_p.add_argument("--np", action="store_true")
    listsongs_p.set_defaults(func=ls)

    show_p = subparsers.add_parser("show")
    show_p.add_argument("alias")
    show_p.add_argument("-f", nargs="?", const="")
    show_p.set_defaults(func=show)

    find_p = subparsers.add_parser("find")
    find_p.add_argument("pattern")
    find_p.set_defaults(func=find)

    addsongs_p = subparsers.add_parser("addsongs")
    addsongs_p.add_argument("alias")
    addsongs_p.add_argument("collection")
    addsongs_p.set_defaults(func=add_songs)

    removesongs_p = subparsers.add_parser("rmsongs")
    removesongs_p.add_argument("alias")
    removesongs_p.add_argument("collection")
    removesongs_p.set_defaults(func=remove_songs)

    check_p = subparsers.add_parser("check")
    check_p.set_defaults(func=check)

    edit_p = subparsers.add_parser("edit")
    edit_p.set_defaults(func=edit)

    if len(sys.argv) == 1:
        cmd = input_box("mpdc-collections", "Command for mpdc-collections:")
        if cmd is None or not cmd:
            sys.exit(0)
        if cmd.startswith("addsongs") or cmd.startswith("rmsongs"):
            lex = shlex.shlex(cmd, posix=True)
            lex.whitespace_split = True
            lex.commenters = ""
            cmd = [next(lex), next(lex), lex.instream.read()]
        else:
            cmd = cmd.split(" ", 1)
        args = argparser.parse_args(cmd)
    else:
        args = argparser.parse_args()

    args.func(args)

    if collectionsmanager.need_update:
        collectionsmanager.write_file()
        collectionsmanager.update_cache()
        cache.write("playlists", mpd.get_stored_playlists_info())
Ejemplo n.º 2
0
def main():
    argparser = argparse.ArgumentParser(add_help=False)
    subparsers = argparser.add_subparsers()

    listsongs_p = subparsers.add_parser('ls')
    listsongs_p.add_argument('collection', nargs='?')
    listsongs_p.add_argument('-m', action='store_true')
    listsongs_p.add_argument('-p', action='store')
    listsongs_p.set_defaults(func=ls)

    show_p = subparsers.add_parser('show')
    show_p.add_argument('alias')
    show_p.add_argument('-m', action='store_true')
    show_p.set_defaults(func=show)

    find_p = subparsers.add_parser('find')
    find_p.add_argument('pattern')
    find_p.set_defaults(func=find)

    addsongs_p = subparsers.add_parser('addsongs')
    addsongs_p.add_argument('alias')
    addsongs_p.add_argument('collection')
    addsongs_p.set_defaults(func=add_songs)

    removesongs_p = subparsers.add_parser('rmsongs')
    removesongs_p.add_argument('alias')
    removesongs_p.add_argument('collection')
    removesongs_p.set_defaults(func=remove_songs)

    removesongs_p = subparsers.add_parser('check')
    removesongs_p.set_defaults(func=check)

    if len(sys.argv) == 1:
        cmd = input_box('mpdc-collections', 'Command for mpdc-collections:')
        if cmd is None or not cmd:
            sys.exit(0)
        if cmd.startswith('addsongs') or cmd.startswith('rmsongs'):
            lex = shlex.shlex(cmd, posix=True)
            lex.whitespace_split = True
            lex.commenters = ''
            cmd = [next(lex), next(lex), lex.instream.read()]
        else:
            cmd = cmd.split(' ', 1)
        args = argparser.parse_args(cmd)
    else:
        args = argparser.parse_args()

    args.func(args)

    if collectionsmanager.need_update:
        collectionsmanager.write_file()
        collectionsmanager.update_cache()
        write_cache('playlists', mpd.get_stored_playlists_info())
Ejemplo n.º 3
0
def update(args):
    mpd.update_cache()
    write_cache('playlists', mpd.get_stored_playlists_info())
    collectionsmanager.feed(force=True)
    collectionsmanager.update_cache()