def afp_shell(args):
    my_args = copy.copy(args)
    running = True
    parser = LibyoArgumentParser(prog="AFP Shell",may_exit=False,autoprint_usage=False,error_handle=sys.stdout)
    parser.add_argument("id",help="VideoID / URL / literals '+exit', '+pass', '+print'", metavar="OPERATION")
    parser.add_argument("-s","--switches",dest="switches",help="Set enabled switches (u,x,f,n,v,s)",choices=switchchoice(["u","x","f","n","v","s"]),metavar="SW")
    parser.add_argument("-a","--avc",dest="avc",help="Set Profile",choices=cichoice(profiles.profiles.keys()),metavar="PROFILE")
    parser.add_argument("-q","--quality",dest="quality",help="Set Quality Level",choices=qchoice.new(1080,720,480,360,240))
    parser.add_argument("-c","--cmd",dest="command",help="set command")
    if HAS_READLINE:
        readline.parse_and_bind("\eA: previous-history")
        readline.parse_and_bind("\eB: next-history")
    else:
        print("WARNING: No Readline extension found. Readline functionality will NOT be available. If you're on Windows you might want to consider PyReadline.")
    sw = my_args.switches = ("u" if args.extract_url else "")+("x" if args.xspf else "")+("f" if args.force else"")+("n" if not args.quiet else "")+("v" if args.verbose else "")+("s" if args.sub else "")
    while running:
        line = input("{0}> ".format(args.prog))
        try:
            parser.parse_args(shlex.split(line), my_args)
        except SystemExit:
            print("""Use "+pass --help" to show available options""")
            continue
        if sw != my_args.switches:
            my_args.extract_url = "u" in my_args.switches
            my_args.xspf = "x" in my_args.switches
            my_args.force = "f" in my_args.switches
            my_args.quiet = "n" not in my_args.switches
            my_args.verbose = "v" in my_args.switches
            my_args.sub = "s" in my_args.switches
            sw = my_args.switches
        if my_args.id =="+pass":
            continue
        elif my_args.id == "+print":
            print("Switches: [{0}]\nProfile: {1}p {2}\nCommand: {3}".format(my_args.switches,my_args.quality,my_args.avc,my_args.command))
            continue
        elif my_args.id == "+exit":
            running = False
            break
        else:
            try:
                process(my_args)
            except YouTubeException:
                print(sys.exc_info()[1])
    #end while
    return 0
def main(ARGC,ARGV):
    welcome()
    parser = ArgumentParser(prog=ARGV[0],formatter_class=RawTextHelpFormatter,
                            description="Playback YouTube Videos without flashplayer")
    parser.add_argument("id", metavar="VideoID", type=str, help="The YouTube Video ID")
    parser.add_argument("-u","--url", dest="extract_url", action="store_true", default=False, help="VideoID is a URL; Extract the ID from it.")
    parser.add_argument("-q","--quality", metavar="Q", dest="quality", action="store", choices=qchoice.new(1080,720,480,360,240), default="480", help="Quality (Will automatically lower Quality if not avaiable!) [Default: %(default)sp]")
    parser.add_argument("-a","--avc", metavar="PRF", dest="avc", action="store", choices=cichoice(profiles.profiles.keys()), default=firstkey(profiles.profiles), help="What Profile to use [Default: %(default)s]\nUse '%(prog)s -i profiles' to show avaliable choices")
    parser.add_argument("-f","--force",dest="force",action="store_true",default=False,help="Force Quality Level (don't jump down)")
    parser.add_argument("-y","--fmt",dest="fmt",metavar="FMT",action="store",type=int,choices=profiles.descriptions.keys(),help="Specify FMT Level. (For Advanced Users)\nUse '%(prog)s -i fmt' to show known Values")
    parser.add_argument("-c","--cmd", metavar="CMD", dest="command", default="vlc %u vlc://quit --sub-file=%s", action="store", help="Media PLayer Command. use \x25\x25u for url"); #use %% to get around the usage of % formatting in argparse
    parser.add_argument("-n","--not-quiet",dest="quiet",action="store_false",default=True,help="Show Media Player Output")
    parser.add_argument("-x","--xspf",dest="xspf",action="store_true",default=False,help="Don't Play the URL directly, but create a XSPF Playlist and play that. (With Title Information etc.)")
    parser.add_argument("-s","--sub",dest="sub",action="store_true",default=False,help="Enable Subtitles (use %%s in the cmd for subtitlefile)")
    parser.add_argument("-i","--internal",dest="int",action="store_true",default=False,help="Treat VideoID as AFP internal command\nUse '%(prog)s -i help' for more Informations.")
    parser.add_argument("-v","--verbose",dest="verbose",action="store_true",default=False,help="Output more Details")
    #parser.add_argument("-s","--shell",dest="shell",action="store_true",default=False,help="Run internal Shell")
    args    = parser.parse_args(ARGV[1:])
    args.id = args.id.lstrip("\\")
    args.prog = parser.prog

    if args.int:
        return internal_cmd(args)
    #elif args.shell:
    #    return afp_shell(args)
    else:
        return process(args)